/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --text-muted: #999;
  --text-dim: #bbb;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --sidebar-width: 240px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

/* ===== Layout ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.channel-sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 20px 16px;
}

.sidebar-brand {
  overflow: hidden;
  white-space: nowrap;
}

.app-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.sidebar-user-count {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
  white-space: nowrap;
}

.channel-sidebar.collapsed .sidebar-brand,
.channel-sidebar.collapsed .sidebar-user-count,
.channel-sidebar.collapsed .channel-info,
.channel-sidebar.collapsed .sidebar-user-name,
.channel-sidebar.collapsed .btn-logout span,
.channel-sidebar.collapsed .btn-new-channel span {
  display: none;
}

.channel-sidebar.collapsed .channel-item {
  justify-content: center;
  padding: 10px;
}

.channel-sidebar.collapsed .sidebar-actions {
  display: flex;
  justify-content: center;
}
.channel-sidebar.collapsed .btn-new-channel {
  width: 36px;
  padding: 8px;
  justify-content: center;
}

.channel-sidebar.collapsed .sidebar-user {
  justify-content: center;
}
.channel-sidebar.collapsed .btn-logout {
  padding: 6px;
  min-width: auto;
  border-radius: 6px;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.channel-item {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  gap: 2px;
  overflow: hidden;
  white-space: nowrap;
}

.channel-item:hover {
  background: #f5f5f5;
}

.channel-item.active {
  background: #eef2ff;
  color: var(--accent);
  font-weight: 500;
}

.channel-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.channel-name {
  font-weight: inherit;
}

.channel-desc {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-actions {
  padding: 0 12px 12px;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* ===== Channel View ===== */
.channel-view {
  margin: 0 auto;
  padding: 32px 24px;
}

.channel-header {
  margin-bottom: 12px;
}

.channel-header h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
}

.channel-header-desc {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 10px;
}

/* ===== Memo Feed ===== */
.memo-feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ===== Memo Card ===== */
.memo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  transition: box-shadow 0.15s;
  position: relative;
}

.memo-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.memo-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.memo-content {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  padding: 4px 0;
}

.memo-date {
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
  padding: 4px 0;
}

/* ===== Memo Meta ===== */
.memo-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-height 0.2s,
    opacity 0.2s,
    margin-top 0.2s;
}

.memo-meta.visible {
  max-height: 24px;
  opacity: 1;
}

.memo-author {
  color: var(--text-muted);
}

.memo-time {
  color: var(--text-dim);
}

/* ===== Type Badge ===== */
.memo-type-badge {
  font-size: 10px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.badge-idea {
  background: #fef3c7;
  color: #92400e;
}
.badge-key {
  background: #dbeafe;
  color: #1e40af;
}
.badge-bill {
  background: #fce7f3;
  color: #9d174d;
}
.badge-link {
  background: #e0e7ff;
  color: #3730a3;
}
.badge-todo {
  background: #d1fae5;
  color: #065f46;
}
.badge-photo {
  background: #fce7d8;
  color: #9a3412;
}
.badge-other {
  background: #f3f4f6;
  color: #6b7280;
}
.badge-file {
  background: #ede9fe;
  color: #5b21b6;
}

/* ===== Memo Form ===== */
.memo-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.memo-input {
  width: 100%;
  border: none;
  padding: 8px 0;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  resize: none;
  outline: none;
  background: transparent;
  line-height: 1.5;
}

.memo-input::placeholder {
  color: var(--text-dim);
}

.memo-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}

.memo-type-picker {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.type-option {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.15s;
  white-space: nowrap;
}

.type-option:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.type-option.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-submit {
  padding: 8px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-submit:hover {
  background: var(--accent-hover);
}

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

/* ===== Channel Form ===== */
.btn-new-channel {
  width: 100%;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-new-channel:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.channel-form-area {
  padding: 8px 12px 0;
  gap: 6px;
  display: flex;
  flex-direction: column;
}

.channel-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.channel-name-input,
.channel-desc-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.channel-name-input:focus,
.channel-desc-input:focus {
  border-color: var(--accent);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

/* ===== Login Page ===== */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px;
  text-align: center;
}

.login-page h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.login-page p {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.btn-github {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: var(--text);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-github:hover {
  background: #333;
}

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.btn-google {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-google:hover {
  border-color: var(--accent);
  background: #f5f3ff;
}

/* ===== Delete Buttons ===== */
.memo-delete {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 0 5px;
  border-radius: 4px;
  line-height: 1;
  height: 22px;
  transition: all 0.15s;
  opacity: 0;
}

.memo-delete.visible {
  opacity: 1;
}

.memo-delete:hover {
  color: #e53e3e;
  background: #fff5f5;
}

.move-wrapper {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
}

.memo-move {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 0 5px;
  border-radius: 4px;
  line-height: 1;
  height: 22px;
  transition: all 0.15s;
  opacity: 0;
}
.memo-move.visible {
  opacity: 1;
}
.memo-move:hover {
  color: var(--accent);
  background: #f5f3ff;
}

.move-picker {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 160px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
  margin-top: 4px;
}
.move-option {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text);
}
.move-option:hover {
  background: var(--bg);
  color: var(--accent);
}

.channel-delete {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.15s;
  opacity: 0;
  flex-shrink: 0;
}

.channel-delete.visible {
  opacity: 1;
}
.channel-delete:hover {
  color: #e53e3e;
  background: #fff5f5;
}

/* ===== Error & Loading ===== */
.error-banner {
  background: #fef2f2;
  color: #b91c1c;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.error-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: inherit;
  margin-left: 8px;
}

.loading-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #818cf8, var(--accent));
  background-size: 200% 100%;
  animation: loading-slide 1.5s infinite;
  border-radius: 2px;
  margin-bottom: 16px;
}

@keyframes loading-slide {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ===== Sidebar User Area ===== */
.sidebar-user-area {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-currency {
  padding: 0 0 4px;
  border-bottom: 1px solid var(--border);
}

.currency-select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  outline: none;
  font-family: inherit;
}
.currency-select:focus {
  border-color: var(--accent);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-user-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.sidebar-user-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-force-refresh {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--text-dim);
  transition: all 0.15s;
}

.btn-force-refresh:hover {
  color: var(--accent);
  background: #f5f3ff;
}

.btn-logout {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-logout:hover {
  border-color: #e53e3e;
  color: #e53e3e;
}

/* ===== Link Memo ===== */
.memo-link-fields {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.memo-link-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: var(--bg);
}

.memo-link-input:focus {
  border-color: var(--accent);
}

.memo-link-actions {
  display: flex;
  gap: 8px;
}

.memo-link-actions .memo-link-input {
  flex: 1;
}

.btn-fetch-preview {
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
}
.btn-fetch-preview:hover {
  background: var(--accent);
  color: white;
}
.btn-fetch-preview:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.link-preview-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-top: 4px;
  overflow: hidden;
}
.link-preview-image {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}
.link-preview-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.link-preview-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-preview-desc {
  font-size: 12px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.memo-link {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s;
  margin-top: 10px;
}
.memo-link:hover {
  box-shadow: var(--shadow);
}

/* ===== Photo Memo ===== */
.memo-photo-fields {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Hide native file input, style the label */
input[type="file"].memo-photo-input {
  display: none;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #f5f3ff;
}
.upload-progress {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.upload-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.upload-progress-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.file-progress-bar {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.file-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.photo-preview {
  margin-top: 8px;
  max-width: 240px;
  position: relative;
}
.photo-preview img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}
.photo-remove:hover {
  background: rgba(0, 0, 0, 0.7);
}

.memo-photo {
  margin-top: 10px;
}
.memo-photo img {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
  display: block;
  background: var(--bg);
  cursor: pointer;
}

/* ===== File Memo ===== */
.memo-files {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.memo-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  text-decoration: none;
  color: inherit;
  font-size: 14px;
}
.memo-file-item:hover {
  background: var(--surface);
}
.memo-file-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.memo-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.memo-file-size {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.memo-file-date {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.memo-file-fields {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.memo-file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.memo-file-upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.memo-file-upload-item .file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.memo-file-upload-item .file-status {
  font-size: 11px;
  color: var(--text-dim);
}
.memo-file-upload-item .file-remove {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-dim);
  padding: 0 4px;
}
.memo-file-upload-item .file-remove:hover {
  color: #e53e3e;
}

/* ===== Todo ===== */
.memo-todo-check {
  width: 20px;
  height: 20px;
  margin-right: 10px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent);
}
.memo-todo-done {
  text-decoration: line-through;
  color: var(--text-dim);
}

/* ===== Bill Memo ===== */
.bill-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.bill-currency {
  width: 80px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  outline: none;
}
.bill-amount {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  outline: none;
}
.bill-amount:focus {
  border-color: var(--accent);
}
.bill-receipt-area {
  margin-top: 8px;
}

.bill-receipt-placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.15s;
  font-family: inherit;
}
.bill-receipt-placeholder:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #f5f3ff;
}

.bill-receipt-icon {
  font-size: 20px;
}

.bill-receipt-text {
  font-size: 13px;
}

.bill-receipt-img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  animation: receipt-load 0.3s ease-out;
}

@keyframes receipt-load {
  from {
    opacity: 0;
    filter: blur(8px);
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
  }
}

.bill-amount-display {
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.bill-currency-symbol {
  font-size: 14px;
  color: var(--text-muted);
}
.bill-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.bill-currency-code {
  font-size: 13px;
  color: var(--text-dim);
  margin-left: 4px;
}

/* ===== Access Key ===== */
.key-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.key-input-row .memo-link-input {
  flex: 1;
}
.btn-reveal-key {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-reveal-key:hover {
  background: #f0f0f0;
}

.memo-access-key {
  margin-top: 10px;
}
.key-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.key-value-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.key-value-text {
  font-size: 13px;
  font-family: "SF Mono", "Fira Code", monospace;
  background: var(--bg);
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Search & Filter ===== */
.memo-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.memo-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.memo-search-input:focus {
  border-color: var(--accent);
}
.memo-search-input::placeholder {
  color: var(--text-dim);
}

.memo-type-filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.filter-chip {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.filter-chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ===== Bill Scan ===== */
.scan-progress {
  font-size: 12px;
  color: var(--accent);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.scan-error {
  font-size: 12px;
  color: #e53e3e;
  margin-top: 6px;
}

.bill-meta {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}
.bill-date {
  color: var(--text-dim);
}

/* ===== Channel Layout (feed + stats) ===== */
.channel-main {
  display: flex;
  gap: 24px;
  justify-content: space-around;
  align-items: flex-start;
}

.channel-sidebar-right {
  width: 256px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 32px;
}

.channel-feed {
  flex: 1;
  min-width: 0;
  max-width: 768px;
}

.stats-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stats-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0;
}

.stats-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.stats-toggle {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s;
}
.stats-toggle:hover {
  background: var(--bg);
  color: var(--text-muted);
}

.stats-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stats-amount {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.stats-count {
  font-size: 12px;
  color: var(--text-muted);
}

.sparkline-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 13px;
}
.sparkline-month {
  color: var(--text-dim);
}
.sparkline-val {
  font-weight: 500;
  color: var(--text);
}
.stats-empty {
  font-size: 13px;
  color: var(--text-dim);
  padding: 8px 0;
}

/* ===== Auth Spinner ===== */
.auth-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Mobile Sidebar Overlay ===== */
.mobile-overlay {
  display: none;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
  .channel-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    transition: transform 0.25s ease;
    box-shadow: none;
  }
  .channel-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }

  .mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .mobile-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .mobile-hamburger {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 8;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    color: var(--text);
    box-shadow: var(--shadow);
  }

  .channel-view {
    padding: 16px 12px;
    padding-top: 56px;
  }

  .channel-main {
    flex-direction: column;
  }

  .channel-sidebar-right {
    width: 100%;
    position: static;
    order: -1;
    margin-bottom: 12px;
    flex-direction: column;
  }
  .stats-card {
    padding: 12px 16px;
  }

  .memo-form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .memo-type-picker {
    justify-content: center;
  }

  .memo-filter-bar {
    flex-direction: column;
  }
  .memo-type-filters {
    justify-content: center;
  }
}

/* ===== Channel Members ===== */
.channel-members {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.members-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.member-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.member-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--bg);
  border-radius: 20px;
  font-size: 13px;
}
.member-name {
  color: var(--text);
}
.member-role {
  font-size: 10px;
  color: var(--text-dim);
}
.member-role.owner {
  color: var(--accent);
  font-weight: 500;
}
.member-invite {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.member-invite-input {
  flex: none;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.member-invite-input:focus {
  border-color: var(--accent);
}
.btn-invite {
  width: 100%;
  padding: 6px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.btn-invite:hover {
  background: var(--accent-hover);
}
.member-error {
  font-size: 12px;
  color: #e53e3e;
  margin-top: 6px;
}

/* ===== Infinite Scroll ===== */
.infinite-scroll-sentinel {
  height: 1px;
}

.loading-spinner {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.end-of-feed {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-dim);
  font-size: 13px;
}
