:root {
  --bg: #f4f7fb;
  --sidebar: #ffffff;
  --panel: #ffffff;
  --panel-border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #4f8ef7;
  --primary-hover: #3b7ae8;
  --accent: #38bdf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --table-head: #e8f2ff;
  --input-bg: #f8fafc;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(160deg, #f8fbff 0%, #eef4fb 45%, #f4f7fb 100%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--sidebar);
  border-right: 1px solid var(--panel-border);
  box-shadow: 2px 0 16px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 16px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.brand h1 {
  font-size: 16px;
  font-weight: 600;
}

.brand p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.nav-item:hover {
  background: rgba(79, 142, 247, 0.08);
  color: var(--text);
}

.nav-item.active {
  background: rgba(79, 142, 247, 0.12);
  color: var(--primary);
  font-weight: 500;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 0;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--panel-border);
  margin-top: 16px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}

.status-dot.online {
  background: var(--success);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid var(--panel-border);
}

.header h2 {
  font-size: 22px;
  font-weight: 600;
}

.header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.header-help-link {
  text-decoration: none;
  white-space: nowrap;
}

.editable-table th[contenteditable="true"],
.editable-table td[contenteditable="true"] {
  cursor: text;
  min-width: 60px;
}

.editable-table th[contenteditable="true"]:focus,
.editable-table td[contenteditable="true"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: rgba(59, 130, 246, 0.08);
}

.workspace {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  padding: 24px 32px;
  flex: 1;
  overflow: hidden;
}

.workspace.memo-mode {
  grid-template-columns: 1fr;
}

.result-panel.memo-full {
  border-left: none;
}

.result-panel.memo-full .result-content {
  max-height: none;
}

#memo-page {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#memo-list {
  margin-top: 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drop-zone {
  border: 2px dashed var(--panel-border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(79, 142, 247, 0.06);
}

.drop-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.drop-zone p {
  font-size: 14px;
  color: var(--text-muted);
}

.drop-zone .link {
  color: var(--primary);
  cursor: pointer;
}

.drop-zone .hint {
  font-size: 12px;
  margin-top: 8px;
}

.text-area label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.text-area textarea,
.extra-options input,
.extra-options select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.extra-options label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.extra-options .option-row {
  margin-bottom: 12px;
}

.actions {
  display: flex;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-primary {
  background: var(--primary);
  color: white;
  flex: 1;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(6, 182, 212, 0.25);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--panel-border);
}

.result-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--panel-border);
}

.result-header h3 {
  font-size: 15px;
}

.meta {
  font-size: 12px;
  color: var(--text-muted);
}

.result-content {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 14px;
}

.result-text {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 14px;
  background: var(--input-bg);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
}

.line-details {
  margin: 8px 0 16px;
}

.line-details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.batch-toolbar {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--input-bg);
}

.batch-toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.batch-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.batch-toolbar-actions label {
  font-size: 13px;
  color: var(--text-muted);
}

.batch-toolbar-actions select {
  margin-left: 6px;
}

.merged-text {
  max-height: 420px;
  overflow: auto;
}

.table-wrap { overflow-x: auto; margin-bottom: 16px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
  text-align: center;
}

.data-table th {
  background: var(--table-head);
  color: #1e40af;
  font-weight: 600;
}

.data-table td:nth-child(2),
.data-table td:nth-child(5) {
  text-align: left;
}

.hint-row {
  font-size: 12px;
  color: var(--text-muted);
}

.field-grid {
  display: grid;
  gap: 10px;
}

.field-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 10px 14px;
  background: var(--input-bg);
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  font-size: 14px;
}

.field-row .key {
  color: var(--text-muted);
}

.field-row .value {
  word-break: break-all;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
}

.tag.warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.tag.danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.section-title {
  font-size: 13px;
  color: var(--accent);
  margin: 20px 0 10px;
  font-weight: 600;
}

.section-title:first-child {
  margin-top: 0;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-item {
  padding: 10px 14px;
  background: var(--input-bg);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
  font-size: 13px;
}

.message-item .sender {
  font-weight: 600;
  color: var(--accent);
  margin-right: 8px;
}

.message-item .time {
  color: var(--text-muted);
  font-size: 11px;
}

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--panel-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  padding: 14px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 14px;
  z-index: 1000;
  transition: opacity 0.3s;
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--danger);
}

.reminder-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.reminder-dialog {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.12);
  max-width: 420px;
  width: 100%;
  padding: 28px 24px;
  animation: reminder-pop 0.25s ease-out;
}

@keyframes reminder-pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.reminder-header {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--accent);
}

.reminder-time {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.reminder-content {
  font-size: 18px;
  line-height: 1.6;
  margin-bottom: 24px;
  word-break: break-word;
}

.reminder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.memo-form textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  resize: vertical;
  min-height: 56px;
}

.memo-form textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

.memo-form input[type="datetime-local"] {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
}

.memo-actions {
  margin-top: 8px;
}

.memo-voice-panel {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 24px;
  margin-bottom: 20px;
  background: var(--input-bg);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
}

.memo-voice-btn {
  flex-shrink: 0;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: linear-gradient(145deg, #dbeafe, #bfdbfe);
  color: #1e40af;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.memo-voice-btn:hover {
  border-color: var(--accent);
}

.memo-voice-btn.recording {
  transform: scale(1.06);
  border-color: var(--danger);
  box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.25);
  background: linear-gradient(145deg, #fecaca, #fca5a5);
  color: #991b1b;
}

.memo-voice-icon {
  font-size: 28px;
  line-height: 1;
}

.memo-voice-label {
  font-size: 12px;
  color: var(--text-muted);
}

.memo-voice-meta {
  flex: 1;
  min-width: 0;
}

.memo-voice-text {
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 6px;
  word-break: break-word;
}

.memo-manual-fallback {
  margin: 12px 0;
  font-size: 13px;
  color: var(--text-muted, #666);
}
.memo-manual-fallback summary {
  cursor: pointer;
  margin-bottom: 8px;
}

.memo-voice-status {
  font-size: 13px;
  color: var(--text-muted);
}

.memo-voice-status.error {
  color: var(--danger);
}

.memo-wxpusher-bind {
  padding: 14px;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.memo-bind-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.memo-wx-qrcode-box {
  text-align: center;
  margin: 12px 0;
}

.memo-wx-qrcode-box img {
  max-width: 200px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
}

.memo-uid-label {
  display: block;
  margin-top: 10px;
  margin-bottom: 6px;
  font-size: 13px;
}

.memo-pushplus-advanced {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.memo-pushplus-advanced input {
  width: 100%;
  margin-top: 8px;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}

.memo-wx-bind-warn {
  color: var(--accent);
  margin-top: 8px;
}

.memo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.memo-item.done {
  opacity: 0.55;
}

.memo-item-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.memo-item-main strong,
.memo-item-main span {
  word-break: break-word;
}

@media (max-width: 960px) {
  .app {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
}
