* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-color: #f7f9fa;
  --card-bg: #ffffff;
  --text-main: #1f2328;
  --text-muted: #656d76;
  --border-color: #d0d7de;
  --primary-color: #0969da;
  --primary-hover: #0856b3;
  --success-color: #1a7f37;
  --danger-color: #cf222e;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lines-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-line {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  height: 42px;
}

.single-line-input {
  flex: 1;
  height: 100%;
  border: none;
  outline: none;
  padding: 0 14px;
  font-size: 15px;
  color: var(--text-main);
  background: transparent;
  white-space: nowrap;
  overflow: hidden;
}

.single-line-input:focus {
  background: #ffffff;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  height: 100%;
  border: none;
  border-left: 1px solid var(--border-color);
  background: #f6f8fa;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease-in-out;
  flex-shrink: 0;
}

.btn-copy:hover {
  background: #ebf0f4;
  color: var(--primary-color);
}

.btn-copy:active {
  background: #e2e7ec;
}

.btn-copy.copied {
  background: #dafbe1;
  color: var(--success-color);
  border-left-color: #aceebb;
}

.editor-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  position: relative;
  min-height: 420px;
}

.editor-content {
  flex: 1;
  padding: 16px;
  padding-bottom: 50px;
  outline: none;
  font-size: 16px;
  line-height: 1.6;
  overflow-y: auto;
  word-break: break-word;
  color: var(--text-main);
}

.btn-save-editor {
  position: absolute;
  bottom: 12px;
  right: 12px;
  padding: 6px 16px;
  background: var(--btn-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
  z-index: 10;
}

.btn-save-editor:hover {
  background: #f3f4f6;
  border-color: #8c959f;
}

.btn-save-editor:active {
  background: #e2e7ec;
}

.btn-save-editor.saved {
  background: #dafbe1;
  color: var(--success-color);
  border-color: #aceebb;
}

.editor-content[data-placeholder]:empty:before {
  content: attr(data-placeholder);
  color: #8c959f;
  cursor: text;
}

.editor-image-item {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin: 10px 0;
  vertical-align: middle;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #f6f8fa;
  user-select: none;
}

.editor-image-item img {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.editor-image-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.editor-image-item:hover .editor-image-overlay,
.editor-image-item.active .editor-image-overlay {
  opacity: 1;
  pointer-events: auto;
}

.btn-img-action {
  background: rgba(31, 35, 40, 0.85);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}

.btn-img-action:hover {
  background: rgba(0, 0, 0, 0.95);
}

.btn-img-action.copied {
  background: var(--success-color);
}

.footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #cf222e;
  transition: background-color 0.2s ease;
}

.status-badge.connected .status-dot {
  background-color: var(--success-color);
}

.status-badge.reconnecting .status-dot {
  background-color: #d97706;
}

.toast-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 35, 40, 0.9);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.toast-msg.show {
  opacity: 1;
}

@media (max-width: 600px) {
  .container {
    padding: 10px;
    gap: 10px;
  }
  .input-line {
    height: 40px;
  }
  .single-line-input {
    font-size: 14px;
    padding: 0 10px;
  }
  .btn-copy {
    padding: 0 12px;
    font-size: 12px;
  }
  .editor-wrapper {
    min-height: 350px;
  }
  .editor-image-overlay {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Storage Section */
.storage-container {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.storage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f6f8fa;
  border-bottom: 1px solid var(--border-color);
}

.storage-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.storage-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.storage-badge {
  font-size: 11px;
  background: #eaeef2;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.storage-header-actions {
  display: flex;
  gap: 6px;
}

.btn-storage-upload {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #ffffff;
  color: var(--primary-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-storage-upload:hover {
  background: #f0f6fc;
  border-color: var(--primary-color);
}

.storage-dropzone {
  min-height: 48px;
  max-height: 220px;
  overflow-y: auto;
  position: relative;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.storage-dropzone.dragover {
  background-color: #f0f8ff;
  outline: 2px dashed var(--primary-color);
  outline-offset: -4px;
}

.storage-empty-hint {
  padding: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  user-select: none;
}

.storage-file-list {
  display: flex;
  flex-direction: column;
}

.storage-item-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f0f2f5;
  height: 38px;
  padding: 0 12px;
  transition: background-color 0.1s ease;
}

.storage-item-line:last-child {
  border-bottom: none;
}

.storage-item-line:hover {
  background-color: #f8fafc;
}

.storage-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
  font-size: 13px;
}

.storage-item-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.storage-item-name {
  font-weight: 500;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storage-item-size {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.storage-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 12px;
}

.btn-storage-action {
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background: #ffffff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-storage-action.btn-download {
  color: var(--primary-color);
}

.btn-storage-action.btn-download:hover {
  background: #f0f6fc;
  border-color: var(--primary-color);
}

.btn-storage-action.btn-delete {
  color: var(--danger-color);
}

.btn-storage-action.btn-delete:hover {
  background: #ffebe9;
  border-color: var(--danger-color);
}

.storage-progress-wrap {
  padding: 8px 12px;
  background: #f6f8fa;
  border-top: 1px solid var(--border-color);
}

.storage-progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.storage-progress-bar {
  width: 100%;
  height: 6px;
  background: #e1e4e8;
  border-radius: 3px;
  overflow: hidden;
}

.storage-progress-fill {
  height: 100%;
  background: var(--primary-color);
  border-radius: 3px;
  transition: width 0.2s ease;
}

/* Auth Modal */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.auth-modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.auth-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #f0f6fc;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.auth-view {
  width: 100%;
}

.auth-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.auth-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
  line-height: 1.4;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.auth-input-group {
  width: 100%;
}

.auth-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  background: #ffffff;
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.15);
}

.auth-input:disabled {
  background: #f6f8fa;
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: #e1e4e8;
}

.btn-auth-submit {
  width: 100%;
  height: 40px;
  background: var(--primary-color);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-auth-submit:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-auth-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-footer-link {
  margin-top: 6px;
}

.auth-text-link {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
  text-decoration: underline;
}

.auth-text-link:hover {
  color: var(--primary-hover);
}

.auth-alert {
  margin-top: 14px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: #ffebe9;
  border: 1px solid #ff8182;
  color: var(--danger-color);
  font-size: 13px;
  text-align: left;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-footer-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.btn-footer-link:hover {
  color: var(--text-main);
  background: #eaeef2;
}

