/* ===== 予定共有 — Discord風ダークテーマ ===== */
:root {
  --bg: #1e2127;
  --rail: #17191f;
  --sidebar: #22252c;
  --surface: #2b2f38;
  --surface-2: #333844;
  --surface-3: #3d4351;
  --line: #3a3f4b;
  --text: #e7eaf0;
  --muted: #98a1b2;
  --accent: #7c6cf0;
  --accent-2: #5865f2;
  --blue: #4fa3ff;
  --yes: #2ecc8b;
  --maybe: #f0b429;
  --no: #ef5f6b;
  --radius: 12px;
  --rail-w: 76px;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ===== 汎用 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: #4752c4; }
.btn.danger { background: transparent; border-color: #63323a; color: #ff9aa4; }
.btn.danger:hover { background: #3a2530; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); }
.input, .field input, .field textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 9px;
  background: #1b1e24;
  border: 1px solid var(--line);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .field input:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 108, 240, .22);
}
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; margin-bottom: 14px; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.form-error { color: #ff8f9a; font-size: 13px; min-height: 18px; margin: 4px 0 0; }
.hint { color: var(--muted); font-size: 13px; }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  flex: 0 0 auto;
  object-fit: cover;
  overflow: hidden;
  background: #4a5060;
  user-select: none;
}

/* ===== ログイン画面 ===== */
.auth {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(124,108,240,.22), transparent 60%),
    radial-gradient(700px 420px at 100% 100%, rgba(79,163,255,.16), transparent 60%),
    var(--bg);
}
.auth-card {
  width: min(100%, 430px);
  background: var(--sidebar);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.auth-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.auth-logo { font-size: 34px; }
.auth-brand h1 { margin: 0; font-size: 22px; }
.auth-brand p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.auth-tabs { display: flex; gap: 6px; background: #1b1e24; padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.auth-tab {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}
.auth-tab.active { background: var(--surface-2); color: var(--text); }
.auth-note { color: var(--muted); font-size: 12px; margin: 14px 0 0; line-height: 1.7; }

/* ===== レイアウト ===== */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.rail {
  width: var(--rail-w);
  flex: 0 0 var(--rail-w);
  background: var(--rail);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  overflow-y: auto;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-item {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  transition: border-radius .15s, background .15s, transform .15s;
  color: var(--text);
}
.rail-item:hover { background: var(--accent-2); border-radius: 13px; transform: translateY(-1px); }
.rail-item.active { background: var(--accent-2); border-radius: 13px; }
.rail-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 26px;
  border-radius: 0 4px 4px 0;
  background: #fff;
}
.rail-add { color: var(--muted); font-size: 24px; font-weight: 400; }
.rail-add:hover { color: #fff; }
.rail-sep { width: 32px; height: 1px; background: var(--line); margin: 2px 0; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.sidebar-head {
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  font-size: 15px;
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 56px;
}
.sidebar-head .g-icon { font-size: 18px; }
.sidebar-head .g-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channels { flex: 1; overflow-y: auto; padding: 10px 8px; }
.channel {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  margin-bottom: 2px;
}
.channel:hover { background: var(--surface); color: var(--text); }
.channel.active { background: var(--surface-3); color: #fff; }
.channel .ico { width: 18px; text-align: center; }
.user-panel {
  border-top: 1px solid var(--line);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: #1e2128;
}
.user-panel .u-meta { flex: 1; min-width: 0; }
.user-panel .u-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-panel .u-sub { font-size: 11px; color: var(--muted); }
.icon-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 15px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
.main-head {
  min-height: 56px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #24272f;
}
.main-head h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.main-head .spacer { flex: 1; }
.main-head .sub { color: var(--muted); font-size: 12px; }
.main-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.mobile-only { display: none; }

/* ===== カレンダー ===== */
.cal-wrap { flex: 1; min-height: 0; overflow: auto; padding: 14px 18px 22px; }
.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { padding: 7px 15px; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--accent-2); color: #fff; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav strong { font-size: 16px; min-width: 128px; text-align: center; }
.cal-nav button {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}
.cal-nav button:hover { background: var(--surface-3); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-left: auto; }
.legend i { font-style: normal; font-weight: 800; }
.legend .y { color: var(--yes); }
.legend .m { color: var(--maybe); }
.legend .n { color: var(--no); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.cal-dow {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  padding: 4px 0;
}
.cal-dow.sun { color: #ff9aa4; }
.cal-dow.sat { color: #8fb8ff; }

.day-cell {
  position: relative;
  min-height: 96px;
  padding: 7px 8px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: background .12s, border-color .12s, transform .12s;
  overflow: hidden;
}
.day-cell:hover { background: var(--surface-2); border-color: #4b5264; }
.day-cell.out { opacity: .38; }
.day-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(124,108,240,.5); }
.day-cell.best { background: linear-gradient(180deg, rgba(46,204,139,.18), rgba(46,204,139,.05)); border-color: rgba(46,204,139,.65); }
.day-cell .dnum { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.day-cell .best-tag {
  font-size: 10px;
  font-weight: 800;
  color: #06281c;
  background: var(--yes);
  border-radius: 999px;
  padding: 1px 6px;
}
.day-cell .counts { display: flex; gap: 8px; font-size: 11px; font-weight: 700; margin-top: auto; }
.counts .y { color: var(--yes); }
.counts .m { color: var(--maybe); }
.counts .n { color: var(--no); }
.my-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #10131a;
}
.my-mark.yes { background: var(--yes); }
.my-mark.maybe { background: var(--maybe); }
.my-mark.no { background: var(--no); }
.my-mark.none { background: transparent; border: 1px dashed var(--line); color: var(--muted); }

/* 週表示 */
.week-list { display: flex; flex-direction: column; gap: 8px; }
.week-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.week-card.today { border-color: var(--accent); }
.week-card.best { border-color: rgba(46,204,139,.65); background: rgba(46,204,139,.07); }
.week-date { min-width: 96px; }
.week-date .wd { font-size: 12px; color: var(--muted); }
.week-date .wn { font-size: 19px; font-weight: 800; }
.week-date .wd.sun { color: #ff9aa4; }
.week-date .wd.sat { color: #8fb8ff; }
.week-answers { flex: 1; min-width: 180px; display: flex; flex-wrap: wrap; gap: 6px; }
.person {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #20242b;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px 3px 4px;
  font-size: 12px;
  max-width: 100%;
}
.person .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.mark { font-weight: 800; }
.mark.yes { color: var(--yes); }
.mark.maybe { color: var(--maybe); }
.mark.no { color: var(--no); }
.answer-buttons { display: flex; gap: 6px; }
.answer-buttons button {
  width: 42px; height: 34px;
  border-radius: 9px;
  background: #20242b;
  border: 1px solid var(--line);
  font-weight: 800;
  color: var(--muted);
  transition: transform .1s, background .12s, color .12s, border-color .12s;
}
.answer-buttons button:hover { transform: translateY(-1px); background: var(--surface-3); color: var(--text); }
.answer-buttons button.on.yes { background: var(--yes); border-color: var(--yes); color: #06281c; }
.answer-buttons button.on.maybe { background: var(--maybe); border-color: var(--maybe); color: #2c1f00; }
.answer-buttons button.on.no { background: var(--no); border-color: var(--no); color: #2b0a0e; }

.empty {
  margin: 26px auto;
  max-width: 460px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 26px 20px;
  background: rgba(255,255,255,.02);
}
.empty h3 { color: var(--text); margin: 0 0 6px; }

/* ===== チャット ===== */
.chat-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg .body { min-width: 0; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg .who { font-weight: 800; font-size: 14px; }
.msg .when { font-size: 11px; color: var(--muted); }
.msg .text { white-space: pre-wrap; word-break: break-word; font-size: 14.5px; }
.msg.mine .who { color: var(--accent); }
.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
  background: #24272f;
}
.chat-form input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 10px;
  background: #1b1e24;
  border: 1px solid var(--line);
  color: var(--text);
  outline: none;
}
.chat-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,108,240,.2); }

/* ===== メンバー / 設定 ===== */
.list-wrap { flex: 1; overflow-y: auto; padding: 16px 18px 24px; }
.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
}
.member-row .info { flex: 1; min-width: 0; }
.member-row .nm { font-weight: 700; }
.member-row .sub { font-size: 12px; color: var(--muted); }
.tag {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
}
.tag.owner { background: rgba(124,108,240,.28); color: #cfc7ff; }

.panel {
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 14px;
}
.panel h3 { margin: 0 0 4px; font-size: 15px; }
.panel p.hint { margin: 0 0 14px; }
.invite-row { display: flex; gap: 8px; }
.invite-row input { flex: 1; font-size: 12px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ===== モーダル / トースト ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, .68);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal {
  width: min(100%, 520px);
  max-height: 88vh;
  overflow: auto;
  background: #262a33;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 26px 70px rgba(0,0,0,.5);
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal .modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal-close { position: sticky; top: 0; float: right; }

.toast-root { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--accent-2);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
  animation: toastIn .18s ease-out;
}
.toast.error { background: #b33a46; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ===== レスポンシブ ===== */
@media (max-width: 860px) {
  .mobile-only { display: inline-flex; }
  .rail { width: 62px; flex-basis: 62px; }
  .rail-item { width: 40px; height: 40px; font-size: 19px; border-radius: 13px; }
  .rail-item.active::before { left: -8px; }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 258px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 12px 0 40px rgba(0,0,0,.5);
  }
  .sidebar.open { transform: translateX(0); }
  .main-head { padding: 9px 12px; min-height: 52px; }
  .cal-wrap, .list-wrap { padding: 12px 12px 20px; }
  .day-cell { min-height: 64px; padding: 6px; border-radius: 8px; gap: 3px; }
  .day-cell .dnum { font-size: 12px; }
  .day-cell .counts { font-size: 10px; gap: 5px; }
  .day-cell .best-tag { display: none; }
  .legend { display: none; }
  .chat-list { padding: 12px; }
  .chat-form { padding: 10px 12px 14px; }
  .modal { padding: 16px; }
  .week-card { padding: 10px; }
  .invite-row { flex-direction: column; }
}

@media (max-width: 520px) {
  .rail { display: none; }
  .cal-grid { gap: 4px; }
  .day-cell { min-height: 58px; }
  .answer-buttons button { width: 38px; }
}
