/* Aikuto Moments PWA - app.css (v1.24.0) */
:root {
  --system-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --app-font: var(--system-font);
  --bg: #000000;
  --bg-sec: #1c1c1e; /* iOS Dark Card */
  --bg-ter: #2c2c2e; /* Input bg */
  --fg: #ffffff;
  --fg-sec: #8e8e93;
  --fg-ter: #48484a;
  --accent: #0a84ff; /* iOS Blue */
  --accent-light: rgba(10, 132, 255, 0.15);
  --danger: #ff453a;
  --border: rgba(255, 255, 255, 0.12);
  --radius: 12px;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

:root[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-sec: #ffffff;
  --bg-ter: #ececf1;
  --fg: #111113;
  --fg-sec: #5f6066;
  --fg-ter: #8a8b92;
  --accent: #006ee6;
  --accent-light: rgba(0, 110, 230, 0.12);
  --danger: #d92d20;
  --border: rgba(0, 0, 0, 0.10);
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

:root[data-theme="auto"] {
  color-scheme: light dark;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #f5f5f7;
    --bg-sec: #ffffff;
    --bg-ter: #ececf1;
    --fg: #111113;
    --fg-sec: #5f6066;
    --fg-ter: #8a8b92;
    --accent: #006ee6;
    --accent-light: rgba(0, 110, 230, 0.12);
    --danger: #d92d20;
    --border: rgba(0, 0, 0, 0.10);
    color-scheme: light;
  }
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--app-font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Layout */
.am-app { display: flex; flex-direction: column; min-height: 100vh; }
.am-main {
  flex: 1;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(40px + var(--safe-bottom));
}
.am-system-bar {
  margin-bottom: 10px;
  border: 1px solid rgba(10,132,255,0.24);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--fg-sec);
  background: rgba(10,132,255,0.08);
  font-size: 12px;
  line-height: 1.4;
}
.am-sync-line {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--fg-sec);
  background: rgba(255,255,255,0.035);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}
.am-system-bar[data-state="error"],
.am-sync-line[data-state="error"] { color: var(--danger); border-color: rgba(255,69,58,0.32); }
.am-system-bar[data-state="warn"],
.am-sync-line[data-state="offline"] { color: #ffd60a; border-color: rgba(255,214,10,0.28); }
.am-sync-line[data-state="cloud"] { color: #30d158; border-color: rgba(48,209,88,0.28); }
.am-install-bar,
.am-update-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(14px + var(--safe-bottom));
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
  border: 1px solid rgba(10,132,255,0.28);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--fg);
  background: rgba(28,28,30,0.96);
  box-shadow: 0 12px 36px rgba(0,0,0,0.42);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  font-size: 13px;
}

.am-tabs {
  position: sticky;
  top: calc(49px + var(--safe-top));
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(28,28,30,0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.am-tab {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--fg-sec);
  font-size: 13px;
  padding: 10px 6px;
  font-weight: 600;
}
.am-tab.is-active {
  background: var(--bg-ter);
  color: var(--fg);
}

/* Header */
.am-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(28, 28, 30, 0.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--border);
  padding-top: var(--safe-top);
}
:root[data-theme="light"] .am-header {
  background: rgba(255,255,255,0.86);
}
:root[data-theme="light"] .am-tabs {
  background: rgba(255,255,255,0.9);
}
:root[data-theme="light"] .am-modal-panel {
  background: #ffffff;
}
:root[data-theme="light"] .am-modal-bd {
  color: #33343a;
}
.am-header__inner {
  height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
}
.am-brand { font-weight: 700; font-size: 17px; letter-spacing: -0.5px; }
.am-nav-link { 
  display: flex; align-items: center; gap: 4px;
  color: var(--accent); text-decoration: none; font-size: 15px; 
}

/* Compose Area */
.am-compose-area {
  background: var(--bg-sec);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid rgba(255,255,255,0.08);
}
.am-compose-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.am-compose-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.am-compose-title {
  color: var(--fg);
  font-size: 16px;
  font-weight: 700;
}
.am-compose-sub {
  margin-top: 3px;
  color: var(--fg-ter);
  font-size: 12px;
}

/* Inputs */
.am-input-group { display: flex; flex-direction: column; gap: 8px; }
.am-input-title {
  background: transparent; border: none; color: var(--fg);
  font-size: 17px; font-weight: 600; padding: 8px 0;
  outline: none;
}
.am-input-content {
  background: transparent; border: none; color: var(--fg);
  font-size: 18px; line-height: 1.55; padding: 0;
  min-height: 160px; resize: vertical; outline: none;
  font-family: inherit;
}
.am-input-title::placeholder, .am-input-content::placeholder { color: var(--fg-ter); }

/* Media Grid */
.am-media-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 12px;
}
.am-media {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  background: #000;
}
.am-media img, .am-media video { width: 100%; height: 100%; object-fit: cover; }
.am-media__x {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: 1px solid rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; padding: 0; cursor: pointer;
}

/* Media Tools */
.am-media-tools { margin-top: 12px; }
.am-add-btn {
  width: 96px; height: 96px; background: var(--bg-ter);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: var(--fg-sec); cursor: pointer;
}
.am-add-btn:active { background: #3a3a3c; }

.am-media-options {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  margin-top: 16px; padding-top: 12px; border-top: 0.5px solid var(--border);
}
.am-upload-switches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 12px 14px;
  flex: 1;
}
.am-checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.am-checkbox-label input[type="checkbox"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}
.am-select-label { display: inline-flex; align-items: center; gap: 8px; }
.am-select-mini {
  appearance: none; -webkit-appearance: none;
  background: var(--bg-ter); color: var(--fg-sec); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 22px 5px 10px; font-size: 12px; outline: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-sec) 50%), linear-gradient(135deg, var(--fg-sec) 50%, transparent 50%);
  background-position: calc(100% - 12px) 50%, calc(100% - 8px) 50%;
  background-size: 4px 4px, 4px 4px; background-repeat: no-repeat;
}
.am-checkbox-custom {
  width: 18px; height: 18px; border: 1.5px solid var(--fg-sec); border-radius: 50%;
  position: relative; transition: 0.2s;
}
input:checked + .am-checkbox-custom { border-color: var(--accent); background: var(--accent); }
input:focus-visible + .am-checkbox-custom {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:checked + .am-checkbox-custom::after {
  content:''; position: absolute; left: 5px; top: 2px; width: 4px; height: 8px;
  border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.am-text { font-size: 13px; color: var(--fg-sec); }
.am-media-summary {
  margin-top: 10px; color: var(--fg-ter); font-size: 12px; line-height: 1.5;
  background: rgba(255,255,255,0.035); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px; padding: 8px 10px;
}

/* Buttons */
.am-btn {
  border: none; border-radius: 20px; padding: 0 20px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s;
}
.am-btn:active { opacity: 0.7; }
.am-btn.primary { background: var(--accent); color: #fff; }
.am-btn.primary.lg { width: 100%; padding: 12px; border-radius: 12px; font-size: 16px; }
.am-btn.primary:disabled { background: var(--bg-ter); color: var(--fg-ter); }
.am-btn.ghost { background: transparent; color: var(--fg-sec); border: 1px solid var(--border); }
.am-btn.sm { font-size: 13px; padding: 6px 12px; }

.am-text-btn { background: none; border: none; color: var(--fg-sec); font-size: 13px; padding: 4px 8px; }
.am-text-btn.danger { color: var(--danger); }

/* Action Bar & Auth */
.am-action-bar { margin-top: 16px; }
.am-auth-details { margin-bottom: 16px; }
.am-auth-summary {
  list-style: none; color: var(--fg-sec); font-size: 12px;
  display: flex; align-items: center; gap: 6px; cursor: pointer;
}
.am-auth-summary::-webkit-details-marker { display: none; }
.am-auth-panel {
  margin-top: 10px; background: var(--bg); padding: 12px; border-radius: 8px;
}
.am-desc { margin: 0 0 10px; font-size: 12px; color: var(--fg-ter); }
.am-input-row {
  width: 100%; background: var(--bg-ter); border: none;
  padding: 10px; border-radius: 8px; color: var(--fg);
  font-size: 14px; margin-bottom: 8px; outline: none;
}
.am-auth-actions { display: flex; gap: 8px; margin-top: 4px; }
.am-send-wrapper { display: flex; flex-direction: column; gap: 8px; }
.am-status-text { font-size: 12px; color: var(--fg-sec); text-align: center; height: 16px; }

.am-settings-card {
  background: var(--bg-sec);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 14px;
}
.am-settings-card + .am-settings-card { margin-top: 14px; }
.am-settings-group-title {
  color: var(--fg);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}
:root[data-theme="light"] .am-settings-card {
  border-color: rgba(0,0,0,0.08);
}
.am-setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px);
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
:root[data-theme="light"] .am-setting-row {
  border-bottom-color: rgba(0,0,0,0.07);
}
.am-setting-row:last-of-type { border-bottom: 0; }
.am-setting-row strong {
  display: block;
  color: var(--fg);
  font-size: 14px;
  font-weight: 650;
}
.am-setting-row small {
  display: block;
  margin-top: 3px;
  color: var(--fg-ter);
  font-size: 12px;
  line-height: 1.35;
}
.am-setting-row .am-input-row {
  margin-bottom: 0;
}
.am-setting-row .am-select-mini {
  width: 100%;
  min-width: 128px;
}
.am-settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
}

/* Lists (Drafts/Sent) */
.am-section-title { font-size: 13px; color: var(--fg-sec); font-weight: 500; text-transform: uppercase; margin-bottom: 8px; padding-left: 4px; }
.am-section-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

.am-list-flow { display: flex; flex-direction: column; gap: 10px; }
.am-card-item {
  background: var(--bg-sec); padding: 14px 16px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.07);
  display: flex; flex-direction: column; gap: 6px;
}
.am-card-item__hd { display: flex; justify-content: space-between; align-items: flex-start; }
.am-card-title { font-size: 15px; font-weight: 500; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 80%; }
.am-source-badge {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 10px;
  vertical-align: 1px;
}
.am-card-date { font-size: 11px; color: var(--fg-ter); font-variant-numeric: tabular-nums; }
.am-card-status { font-size: 11px; color: var(--accent); }
.am-card-ft { display: flex; justify-content: flex-end; gap: 12px; margin-top: 4px; padding-top: 8px; border-top: 0.5px solid rgba(255,255,255,0.05); }

/* Modal */
.am-modal { display: none; position: fixed; inset: 0; z-index: 100; }
.am-modal.show { display: block; }
.am-modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); }
.am-modal-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 80%; max-width: 320px; background: #252525; border-radius: 14px;
  overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.am-modal-hd { padding: 16px 16px 0; text-align: center; }
.am-modal-hd h3 { margin: 0; font-size: 17px; }
.am-modal-bd { padding: 16px; font-size: 14px; color: #ddd; text-align: center; line-height: 1.5; }
.am-modal-ft { display: flex; border-top: 0.5px solid rgba(255,255,255,0.15); }
.am-modal-ft button {
  flex: 1; background: transparent; border: none; color: var(--accent);
  padding: 14px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.am-modal-ft button:active { background: rgba(255,255,255,0.05); }
.am-modal-ft button + button { border-left: 0.5px solid rgba(255,255,255,0.15); }

/* Toast */
.am-toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(40, 40, 40, 0.9); color: #fff; padding: 16px 24px;
  border-radius: 12px; font-size: 15px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s; z-index: 110; text-align: center;
}
.am-toast.show { opacity: 1; }
/* v1.2.0+ - Send queue & progress */
.am-helper-text {
  margin: -2px 0 10px;
  padding: 0 4px;
  color: var(--fg-ter);
  font-size: 12px;
  line-height: 1.5;
}
.am-empty {
  text-align: center;
  color: var(--fg-ter);
  font-size: 12px;
  padding: 10px;
}
.am-card-sub {
  color: var(--fg-sec);
  font-size: 12px;
  line-height: 1.55;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.am-queue-list {
  margin-bottom: 4px;
}
.am-queue-item {
  border: 1px solid rgba(10,132,255,0.18);
}
.am-queue-meta,
.am-queue-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--fg-sec);
  font-size: 12px;
  line-height: 1.4;
}
.am-queue-meta span:last-child,
.am-queue-foot span:first-child {
  color: var(--fg-ter);
  white-space: nowrap;
}
.am-progress {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-ter);
  margin: 4px 0 2px;
}
.am-progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.18s ease;
}
.am-queue-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* v1.3.0 - Fast send mode */
.am-queue-item.is-runtime {
  border: 1px solid rgba(10,132,255,0.22);
}
.am-queue-item.is-success {
  border-color: rgba(48, 209, 88, 0.34);
}
.am-queue-item.is-success .am-progress span {
  background: #30d158;
}
.am-queue-item.is-success .am-queue-meta span:first-child {
  color: #30d158;
}
.am-queue-item.is-failed {
  border-color: rgba(255, 69, 58, 0.32);
}
.am-queue-item.is-failed .am-progress span {
  background: var(--danger);
}
.am-queue-item.is-failed .am-queue-meta span:first-child {
  color: var(--danger);
}
@media (max-width: 420px) {
  .am-compose-head { flex-direction: column; align-items: stretch; }
  .am-compose-actions { justify-content: flex-start; }
  .am-media-options { align-items: flex-start; }
  .am-upload-switches { grid-template-columns: 1fr; align-items: flex-start; gap: 10px; }
  .am-select-label { width: 100%; justify-content: space-between; }
  .am-main { padding: 12px; }
  .am-compose-area { padding: 16px; }
  .am-input-content { min-height: 140px; }
  .am-tab { font-size: 12px; padding: 9px 4px; }
  .am-setting-row { grid-template-columns: 1fr; gap: 8px; }
  .am-settings-actions { justify-content: stretch; }
  .am-settings-actions .am-btn { flex: 1; }
}

@media (min-width: 900px) {
  .am-main {
    max-width: 1040px;
    padding: 24px 28px calc(56px + var(--safe-bottom));
  }
  .am-header__inner {
    max-width: 1040px;
    margin: 0 auto;
    padding: 0 28px;
  }
  .am-tabs {
    top: calc(56px + var(--safe-top));
    max-width: 640px;
    margin: 0 auto 20px;
  }
  .am-compose-area {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-areas: "head media" "editor media" "action media";
    max-width: 980px;
    margin: 0 auto 24px;
    gap: 18px 24px;
    padding: 24px;
  }
  .am-compose-head { grid-area: head; margin-bottom: 0; }
  .am-input-group { grid-area: editor; }
  .am-media-area {
    grid-area: media;
    align-self: start;
    margin-top: 0;
    border-left: 1px solid var(--border);
    padding-left: 24px;
  }
  .am-action-bar { grid-area: action; margin-top: 0; }
  .am-input-content {
    min-height: 360px;
    font-size: 19px;
  }
  .am-media-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 0;
  }
  .am-add-btn {
    width: 88px;
    height: 88px;
  }
  .am-media-options {
    display: block;
    margin-top: 14px;
  }
  .am-upload-switches {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .am-select-label {
    width: 100%;
    justify-content: space-between;
    margin-top: 10px;
  }
  #am-clear-media {
    align-self: flex-start;
  }
  .am-history-area {
    max-width: 860px;
    margin: 0 auto;
  }
  .am-settings {
    max-width: 860px;
    margin: 0 auto;
  }
  .am-install-bar,
  .am-update-bar {
    max-width: 720px;
  }
}
