@font-face {
  font-family: "Nunito"; font-weight: 400; font-style: normal;
  src: url("/static/fonts/Nunito-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Nunito"; font-weight: 400; font-style: italic;
  src: url("/static/fonts/Nunito-Italic.ttf") format("truetype");
}
@font-face {
  font-family: "Nunito"; font-weight: 700; font-style: normal;
  src: url("/static/fonts/Nunito-Bold.ttf") format("truetype");
}

:root {
  --bg: #000;
  --fg: #fff;
  --muted: #999;
  --accent: #ffeb3b;
  --card: #161616;
  --border: #2a2a2a;
  --green: #4cd964;
  --past: #555;
  /* Week-color rotation (cyan / orange / red) matches the Flutter version. */
  --week-0: #00bcd4;
  --week-1: #ff9800;
  --week-2: #ff5252;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg); color: var(--fg);
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
}

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  gap: 12px;
}
header h1 {
  font-size: 18px; font-weight: 700; margin: 0; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-right { display: flex; align-items: center; gap: 12px; }
#presence { color: var(--muted); font-size: 13px; }
#who { color: var(--muted); font-size: 13px; }
.who-btn {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 13px; font-weight: 700; padding: 4px 10px;
  cursor: pointer; line-height: 1.4;
}
.who-btn:hover { color: var(--fg); border-color: var(--muted); }
.who-btn:empty { display: none; }

#account-dialog .signed-in { margin: 0 0 4px; color: #333; font-size: 15px; }
#account-dialog .signed-in strong { color: #111; font-weight: 700; }
#account-dialog .footer { display: flex; justify-content: flex-end; padding-top: 10px; }
.account-links { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 0; }
.account-links:empty { display: none; }
.account-links a {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px;
  background: #fff; border: 1px solid #d8cfb8;
  color: #111; text-decoration: none; font-weight: 700; font-size: 15px;
}
.account-links a:hover { background: #faf3df; }
.account-links a svg { width: 18px; height: 18px; fill: currentColor; color: #b8860b; flex-shrink: 0; }

#plan-list .links-btn {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 700;
  cursor: pointer;
}
#plan-list .links-btn:hover { color: var(--accent); border-color: var(--accent); }

.link-rows {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 240px; overflow-y: auto;
}
.link-rows li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border: 1px solid #d8cfb8; border-radius: 6px; background: #fff;
}
.link-rows li:empty { display: none; }
.link-rows .lbl { font-weight: 700; color: #111; flex-shrink: 0; }
.link-rows .url { color: #555; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; font-size: 13px; }
.link-rows .empty { color: #888; font-style: italic; justify-content: center; padding: 10px; }
.link-rows .rm {
  background: transparent; color: #999; border: none; cursor: pointer;
  width: 28px; height: 28px; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
}
.link-rows .rm:hover { color: #b71c1c; background: rgba(183,28,28,0.08); }
#comments-btn {
  background: transparent; color: var(--accent);
  font-size: 22px; border: none; padding: 4px 8px; cursor: pointer;
}
.link-btn {
  background: transparent; color: var(--muted);
  border: none; padding: 6px 8px; cursor: pointer;
  font-size: 13px; font-weight: 700; letter-spacing: 0.04em;
}
.link-btn:hover { color: var(--fg); }

main { padding: 14px; }
main.centered { max-width: 480px; margin: 0 auto; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px; margin-bottom: 14px;
}
.card h2 {
  margin: 0 0 10px; font-size: 15px; color: var(--accent);
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
}
.hidden { display: none; }

input, select, button {
  background: #1c1c1c; color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; font: inherit;
}
input { width: 100%; }
button {
  background: var(--accent); color: #000; cursor: pointer; font-weight: 700;
  padding: 10px 18px;
}
button.secondary { background: #2a2a2a; color: var(--fg); }

form { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

ul { list-style: none; padding: 0; margin: 0; }
#plan-list li {
  display: flex; justify-content: space-between; padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
#plan-list a { color: var(--accent); text-decoration: none; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#plan-list li.empty { color: var(--muted); font-style: italic; justify-content: flex-start; }
#plan-list .rm {
  background: transparent; color: var(--muted); border: none;
  width: 32px; height: 32px; cursor: pointer; font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
}
#plan-list .rm:hover { color: #ff5252; background: rgba(255,82,82,0.08); }

/* ----- Plan grid ----- */
.grid {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  /* landscape default: 56px week-label column, 7 day columns; 3 week rows */
  grid-template-columns: 56px repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(120px, 1fr));
}
.grid .week-label {
  grid-column: 1; grid-row: calc(var(--week) + 1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.95);
  background: var(--week-color-dark);
}
.grid .tile {
  grid-column: calc(var(--day) + 2);
  grid-row: calc(var(--week) + 1);
  background: var(--week-color);
  color: #111;
  border-radius: 6px; padding: 6px 6px 4px;
  cursor: pointer; user-select: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  position: relative; overflow: hidden;
  touch-action: manipulation;
  transition: transform 80ms ease;
}
.grid .tile:active { transform: scale(0.97); }
.grid .tile.past { background: var(--past); color: rgba(255,255,255,0.85); cursor: default; opacity: 0.65; }
.grid .tile.past:active { transform: none; }
.grid .tile.long-pressing { outline: 2px solid #fff; outline-offset: -3px; }

.grid .tile .day-name {
  font-size: 18px; font-weight: 700;
  color: rgba(0,0,0,0.85);
  line-height: 1.1;
}
.grid .tile .names {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 3px;
}
.grid .tile .name {
  font-size: 11px; font-weight: 700;
  background: rgba(0, 0, 0, 0.18); color: #fff;
  padding: 2px 8px; border-radius: 10px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.grid .tile .name.mine { background: var(--green); color: #fff; }

.grid .tile .beer {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 56%; height: auto; max-width: 80px; max-height: 80px;
  pointer-events: none; user-select: none; z-index: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}
.grid .tile .date-wm {
  position: absolute; left: 8px; right: 8px;
  bottom: 2px;
  font-size: 30px; font-weight: 700;
  color: rgba(0, 0, 0, 0.08);
  letter-spacing: 0.02em; line-height: 1;
  text-align: left; pointer-events: none; z-index: 0;
  white-space: nowrap; overflow: hidden;
}
.grid .tile.past .date-wm { color: rgba(255, 255, 255, 0.10); }

.grid .tile .selection {
  position: absolute; bottom: 6px; left: 8px; right: 8px;
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: #fff;
  background: transparent; padding: 0;
  cursor: pointer; z-index: 2;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  overflow: hidden; white-space: nowrap;
  touch-action: manipulation;
}
.grid .tile .selection .label-text {
  overflow: hidden; text-overflow: ellipsis;
}
.grid .tile .selection .ico {
  width: 14px; height: 14px; flex-shrink: 0;
  fill: currentColor; opacity: 0.95;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3));
}
.grid .tile .selection.empty { color: rgba(255, 255, 255, 0.75); }

/* z-index ordering inside the tile */
.grid .tile > .day-name,
.grid .tile > .names { position: relative; z-index: 3; }

/* ----- Portrait: transpose (days as rows, weeks as cols) ----- */
@media (orientation: portrait), (max-width: 700px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: 36px repeat(7, minmax(110px, 1fr));
  }
  .grid .week-label {
    grid-row: 1;
    grid-column: calc(var(--week) + 1);
  }
  .grid .tile {
    grid-column: calc(var(--week) + 1);
    grid-row: calc(var(--day) + 2);
  }
}

/* ----- Dialogs ----- */
dialog:not([open]) { display: none; }
dialog {
  background: var(--card); color: var(--fg);
  border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  min-width: min(420px, 92vw); max-width: 92vw; max-height: 86vh; overflow: auto;
  font-family: inherit;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 0 10px; border: none;
}
dialog header h2 { margin: 0; color: var(--accent); font-size: 16px; }
dialog header button {
  background: transparent; color: var(--fg); border: none;
  font-size: 24px; line-height: 1; cursor: pointer;
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 22px;
}
dialog header button:hover, dialog header button:active {
  background: rgba(255, 255, 255, 0.08);
}
#comments-dialog header button:hover,
#comments-dialog header button:active {
  background: rgba(0, 0, 0, 0.06);
}

/* ----- Light comments dialog ----- */
#comments-dialog {
  background: #fafafa; color: #111;
  border: 1px solid #ddd; width: min(440px, 94vw); height: min(80vh, 640px);
  padding: 0; overflow: hidden;
}
#comments-dialog[open] { display: flex; flex-direction: column; }
#comments-dialog header {
  padding: 12px 14px; border-bottom: 1px solid #e6e6e6;
}
#comments-dialog header h2 { color: #222; }
#comments-dialog header button { color: #555; }

#comment-list {
  list-style: none; padding: 8px 12px; margin: 0;
  overflow-y: auto; flex: 1; background: #fafafa;
}
#comment-list .day-header {
  position: sticky; top: 0; background: #fafafa;
  color: #555; font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 10px 2px 4px; border-bottom: 1px solid #ececec; margin-bottom: 4px;
}
#comment-list .comment {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 0;
}
#comment-list .author-pill {
  flex-shrink: 0;
  font-weight: 700; font-size: 12px;
  padding: 3px 8px; border-radius: 12px; color: #111;
}
#comment-list .bubble { flex: 1; }
#comment-list .text {
  display: block; color: #111; word-wrap: break-word; white-space: pre-wrap;
}
#comment-list .text a { color: #1565c0; }
#comment-list .meta { font-size: 11px; color: #888; margin-top: 2px; }

#add-comment {
  display: flex; gap: 6px; flex-direction: row;
  padding: 10px 12px; border-top: 1px solid #e6e6e6; background: #fff;
}
#add-comment input {
  background: #fff; color: #111; border: 1px solid #ddd; flex: 1;
}
#add-comment button { background: var(--accent); color: #000; }

/* ----- Light dialogs (day-picker, add-restaurant) ----- */
dialog.light {
  background: #f4eddd; color: #111;
  border: 1px solid #d8cfb8;
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
dialog.light header { padding: 0 0 14px; }
dialog.light header h2 { color: #111; font-size: 22px; font-weight: 700; margin: 0; }
dialog.light header button { color: #444; }
dialog.light header button:hover { background: rgba(0,0,0,0.06); }
dialog.light input {
  background: transparent; color: #111;
  border: none; border-bottom: 1px solid #b9b09c;
  border-radius: 0; padding: 8px 0; font-size: 16px;
}
dialog.light input:focus {
  outline: none; border-bottom-color: #111;
}
dialog.light label { color: #555; font-size: 13px; }
dialog.light button.secondary {
  background: transparent; color: #b8860b; border: none;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
dialog.light button.secondary:hover { background: rgba(0,0,0,0.05); border-radius: 6px; }

/* Minimal underline dropdown */
dialog.light .field {
  appearance: none; -webkit-appearance: none;
  background: transparent; color: #111;
  border: none; border-bottom: 1px solid #b9b09c;
  border-radius: 0; padding: 8px 28px 8px 0;
  font: inherit; font-size: 16px;
  background-image: linear-gradient(45deg, transparent 50%, #555 50%),
                    linear-gradient(135deg, #555 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 8px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  width: 100%;
  cursor: pointer;
}
dialog.light .field:focus { outline: none; border-bottom-color: #111; }

dialog.light .field-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
dialog.light .field-row .field { flex: 1; }
dialog.light .day-body > .field { display: block; margin-bottom: 18px; }
dialog.light .day-body .footer { display: flex; justify-content: flex-end; padding-top: 10px; }
dialog.light .text-btn {
  background: transparent; color: #b8860b;
  border: none; padding: 8px 12px; cursor: pointer;
  font-weight: 700; font-size: 15px; letter-spacing: 0.04em;
  text-transform: uppercase;
}
dialog.light .text-btn:hover { background: rgba(0,0,0,0.05); border-radius: 6px; }
dialog.light .text-btn.danger { color: #b71c1c; }
dialog.light .text-btn.danger:hover { background: rgba(183,28,28,0.08); }

dialog.confirm-dialog .__msg { margin: 0; color: #333; font-size: 15px; line-height: 1.4; }

/* link icon next to restaurant dropdown */
dialog.light #day-rest-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 8px; color: #444; flex-shrink: 0;
}
dialog.light #day-rest-link:hover { background: rgba(0,0,0,0.06); color: #111; }
dialog.light #day-rest-link svg { width: 22px; height: 22px; fill: currentColor; }
dialog.light #day-rest-link.hidden { display: none; }

#day-dialog .day-body { display: flex; flex-direction: column; }

.grid .tile .selection .link-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin-left: 2px; flex-shrink: 0;
  border-radius: 4px; color: #fff;
  pointer-events: auto;
}
.grid .tile .selection .link-ico svg { width: 13px; height: 13px; fill: currentColor; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3)); }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #222; color: #fff;
  padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 1000; max-width: 90vw;
}
#toast.show { opacity: 1; }
#toast.error { background: #b71c1c; }
