/* Shared design tokens + base chrome for 通院メモ (edit + view pages). */

@font-face {
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f2f2f0;
  --bg-elevated: #fafafa;
  --card-bg: #fafafa;
  --border: #d9d9d6;
  --border-soft: #e4e4e1;
  --text: #1a1a1a;
  --text-dim: #555;
  --text-faint: #8c8c8c;
  --accent: #1a1a1a;
  --accent-hover: #000;
  --on-accent: #fafafa;
  --accent-dim: #e6e6e3;
  --accent-soft: #cdcdca;
  --danger: #b3261e;
  --danger-dim: #f5e2e0;
  --success: #2e7d32;
  --success-dim: #e2eee2;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-sm: none;
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 0.15s var(--ease);
  --t: 0.25s var(--ease);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1b;
    --bg-elevated: #232323;
    --card-bg: #232323;
    --border: #3a3a3a;
    --border-soft: #2e2e2e;
    --text: #e6e6e6;
    --text-dim: #aaa;
    --text-faint: #777;
    --accent: #e6e6e6;
    --accent-hover: #fff;
    --on-accent: #1b1b1b;
    --accent-dim: #2e2e2e;
    --accent-soft: #474747;
    --danger: #e57368;
    --danger-dim: #3a2422;
    --success: #8bc48e;
    --success-dim: #233023;
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

/* Every font-size in this app is set in rem, so bumping the root size
   scales the whole UI (headings, buttons, hints...) together. */
html {
  font-size: 120%;
}

html, body {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}


::selection { background: var(--accent-soft); }

/* ---------------------------------------------------------------------
   Header
---------------------------------------------------------------------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  background: var(--bg-elevated);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-wrap: wrap;
  transition: background var(--t), border-color var(--t);
}
header h1 { font-size: 1.02rem; margin: 0; font-weight: 600; letter-spacing: 0.01em; color: var(--accent); }
header .header-right { display: flex; align-items: center; gap: 10px; }
header .nav-link {
  color: var(--accent);
  font-size: 0.8rem;
  text-decoration: none;
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  padding: 4px 12px;
  transition: background var(--t-fast), opacity var(--t);
  white-space: nowrap;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}
header .nav-link:hover { background: var(--accent-dim); }
#statusBadge {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  transition: background var(--t-fast), color var(--t-fast), opacity var(--t);
}
#statusBadge.offline { background: var(--danger-dim); color: var(--danger); }
#statusBadge:empty { display: none; } /* online is the expected state — only show the badge when there's something to say */

/* ---------------------------------------------------------------------
   Cards + buttons (shared vocabulary)
---------------------------------------------------------------------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: background var(--t), border-color var(--t), box-shadow var(--t);
}
.card h2 {
  font-size: 0.92rem;
  margin: 0 0 12px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 0.84rem;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: background var(--t-fast), opacity var(--t-fast), transform var(--t-fast);
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.97); }
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.secondary:hover { background: var(--accent-dim); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.danger:hover { background: var(--danger-dim); }
.btn.active { background: var(--accent); color: var(--on-accent); }
.btn:disabled { opacity: 0.5; cursor: default; }


input[type=text], input[type=date], input[type=search], textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text);
  transition: border-color var(--t-fast), background var(--t);
}
input[type=text]:focus, input[type=date]:focus, input[type=search]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------------------------------------------------------------------
   Idle chrome: after a few seconds of no input, secondary controls
   recede so the content itself has the floor. Never fully invisible,
   so touch users without hover can still find + tap them.
---------------------------------------------------------------------- */

.ui-fade { transition: opacity var(--t); }
body.ui-idle .ui-fade { opacity: 0.4; }
.ui-fade:hover, .ui-fade:focus-within { opacity: 1; }

/* Dim blocks unrelated to the thing currently being written. */
.fade-on-editor-focus { transition: opacity var(--t); }
body.editor-focused .fade-on-editor-focus { opacity: 0.45; }

/* Landing-spot flash so a jump (date pick, list click) is visible. */
@keyframes jump-highlight {
  0% { background-color: var(--accent-soft); }
  100% { background-color: transparent; }
}
.jump-highlight { animation: jump-highlight 1.3s var(--ease); }

footer { text-align: center; font-size: 0.7rem; color: var(--text-faint); padding: 18px; }
footer a { color: var(--text-faint); }

.hint { font-size: 0.75rem; color: var(--text-faint); margin-top: 6px; }
.empty-hint { color: var(--text-dim); font-size: 0.85rem; padding: 10px 0; }

/* Keep the memo workspace above the optional analytics panel.  The
   templates contain the chart before the workspace so the chart can be
   initialized early, but visual order should prioritize the latest memo.
   This applies to both edit mode and the read-only guest view. */
body {
  display: flex;
  flex-direction: column;
}
body > header { order: 0; }
body > .app { order: 1; }
body > footer { order: 3; }
body > .app { width: 100%; }

@media (max-width: 860px) {
  body > .app { padding-top: 12px; }
}
