:root {
  color-scheme: dark;
  --ink: #f4f0e7;
  --muted: #9caaa9;
  --bg: #0c1519;
  --surface: #132127;
  --surface-2: #192b32;
  --line: #2b3e43;
  --accent: #e7a64b;
  --accent-soft: #f4cf96;
  --danger: #f18c82;
  --success: #7fc9a4;
  font-family: Inter, "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% 4%, rgba(40, 106, 105, .22), transparent 32rem),
    linear-gradient(135deg, rgba(231, 166, 75, .045) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
}

a { color: var(--accent-soft); }
button, input, select, textarea { font: inherit; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 2.8rem;
  padding: .65rem 1rem;
  border: 1px solid var(--accent);
  border-radius: .5rem;
  color: #16120b;
  background: var(--accent);
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-soft); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(244, 207, 150, .55);
  outline-offset: 2px;
}
button.secondary { color: var(--ink); border-color: var(--line); background: transparent; }
button.secondary:hover { background: var(--surface-2); }
button.ghost { min-height: 2.25rem; padding: .3rem .65rem; color: var(--accent-soft); border-color: transparent; background: transparent; }
button:disabled { opacity: .55; cursor: wait; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .7rem; color: var(--ink); text-decoration: none; letter-spacing: .03em; }
.brand span { display: grid; line-height: 1; }
.brand b { font-family: Georgia, "Yu Mincho", serif; font-size: 1.25rem; }
.brand small { margin-top: .32rem; color: var(--accent); font-size: .62rem; letter-spacing: .2em; }
nav { display: flex; align-items: center; gap: .5rem; }

main { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 4.5rem 0 6rem; }
main:focus { outline: none; }
.hero { max-width: 900px; margin-bottom: 3rem; }
.hero.compact { max-width: none; margin-bottom: 1.5rem; }
.hero.compact h1 { margin-bottom: .7rem; font-size: clamp(2.2rem, 4vw, 3.4rem); }
.hero.compact > p:last-child { margin-bottom: 0; }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .18em; }
h1, h2, h3 { font-family: Georgia, "Yu Mincho", serif; font-weight: 500; }
h1 { margin: .8rem 0 1.3rem; font-size: clamp(2.6rem, 5vw, 4.8rem); line-height: 1.02; letter-spacing: -.045em; text-wrap: balance; }
h1 em { color: var(--accent-soft); font-style: normal; }
.hero > p:last-child { max-width: 760px; color: var(--muted); font-size: 1.05rem; line-height: 1.9; }

.panel { padding: clamp(1.3rem, 3vw, 2.4rem); border: 1px solid var(--line); border-radius: .85rem; background: rgba(19, 33, 39, .88); box-shadow: 0 24px 80px rgba(0, 0, 0, .22); }
.panel + .panel { margin-top: 1rem; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.panel h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.2rem); }
.panel h3 { margin: 0 0 .9rem; font-size: 1.25rem; }
.lede, .muted { color: var(--muted); line-height: 1.7; }
.loading-panel { display: flex; align-items: center; justify-content: center; gap: 1rem; min-height: 12rem; color: var(--muted); }
.spinner { width: 1.2rem; height: 1.2rem; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-card { max-width: 560px; }
form { display: grid; gap: 1rem; }
label { display: grid; gap: .45rem; color: var(--muted); font-size: .88rem; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 2.8rem;
  padding: .72rem .8rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  color: var(--ink);
  background: #0e191e;
}
textarea { min-height: 9rem; resize: vertical; line-height: 1.6; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; }
.error { color: var(--danger); }

.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.ticket-list { display: grid; gap: .7rem; }
.ticket-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .6rem 1rem;
  width: 100%;
  padding: 1rem 1.1rem;
  text-align: left;
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface-2);
}
.ticket-card:hover { border-color: var(--accent); background: #20353b; }
.ticket-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-card small { color: var(--muted); font-weight: 500; }
.badge { display: inline-flex; align-items: center; width: fit-content; padding: .2rem .52rem; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: .74rem; font-weight: 750; }
.badge.new, .badge.urgent { color: var(--danger); border-color: rgba(241, 140, 130, .4); }
.badge.resolved, .badge.closed { color: var(--success); border-color: rgba(127, 201, 164, .4); }

.ticket-meta { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin: .7rem 0 1.5rem; color: var(--muted); font-size: .86rem; }
.message-list { display: grid; gap: .8rem; margin: 1.5rem 0; }
.message { max-width: min(760px, 94%); padding: 1rem; border: 1px solid var(--line); border-radius: .7rem; background: #0e191e; }
.message.customer { justify-self: end; background: #1d3035; }
.message.internal { border-style: dashed; border-color: var(--accent); }
.message-head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .55rem; color: var(--muted); font-size: .75rem; }
.message-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }

.admin-workspace { display: grid; gap: 1rem; align-items: start; }
.admin-workspace.has-detail { grid-template-columns: minmax(0, 1fr) minmax(380px, .72fr); }
.admin-workspace .panel { min-width: 0; margin: 0; }
.admin-queue { padding: clamp(1rem, 2vw, 1.5rem); }
.admin-queue-head { align-items: center; margin-bottom: 1rem; }
.view-switch { display: inline-grid; grid-template-columns: repeat(2, 1fr); padding: .2rem; border: 1px solid var(--line); border-radius: .65rem; background: #0e191e; }
.view-switch button { min-height: 2.25rem; padding: .35rem .75rem; color: var(--muted); border-color: transparent; background: transparent; white-space: nowrap; }
.view-switch button:hover { color: var(--ink); background: var(--surface-2); }
.view-switch button.active { color: #16120b; background: var(--accent); }

.queue-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; margin-bottom: 1rem; }
.queue-stat { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: .55rem; color: var(--muted); background: #0e191e; }
.queue-stat span { overflow: hidden; font-size: .78rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.queue-stat strong { color: var(--ink); font-size: 1.15rem; }
.queue-stat.new { border-color: rgba(241, 140, 130, .35); }
.queue-stat.resolved { border-color: rgba(127, 201, 164, .35); }

.kanban-scroll { overflow-x: auto; padding-bottom: .2rem; scrollbar-color: var(--line) transparent; }
.kanban-board { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: .7rem; min-width: 970px; }
.kanban-column { min-width: 0; padding: .7rem; border: 1px solid var(--line); border-top: 3px solid var(--line); border-radius: .7rem; background: rgba(12, 21, 25, .72); }
.kanban-column.new { border-top-color: var(--danger); }
.kanban-column.in_progress { border-top-color: var(--accent); }
.kanban-column.waiting_customer { border-top-color: #7facc9; }
.kanban-column.resolved { border-top-color: var(--success); }
.kanban-column-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .65rem; }
.kanban-column-head h3 { margin: 0; font-family: inherit; font-size: .85rem; font-weight: 800; }
.kanban-count { display: inline-grid; min-width: 1.65rem; height: 1.65rem; place-items: center; border-radius: 99px; color: var(--muted); background: var(--surface-2); font-size: .75rem; font-weight: 800; }
.kanban-cards { display: grid; gap: .55rem; }
.kanban-card { display: grid; gap: .6rem; width: 100%; min-height: 0; padding: .8rem; text-align: left; color: var(--ink); border-color: var(--line); background: var(--surface); }
.kanban-card:hover, .kanban-card.selected { border-color: var(--accent); background: #20353b; }
.kanban-card strong { overflow: hidden; font-size: .9rem; line-height: 1.45; text-overflow: ellipsis; }
.kanban-card small { color: var(--muted); font-weight: 500; }
.kanban-card-head, .kanban-card-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.kanban-card-foot { color: var(--muted); font-size: .7rem; font-weight: 500; }
.kanban-card-foot time { text-align: right; }
.kanban-empty { padding: 1.35rem .5rem; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: .55rem; font-size: .8rem; }
.board-archive { display: flex; align-items: center; justify-content: flex-end; gap: .35rem; margin-top: .55rem; font-size: .8rem; }

.product-label { overflow: hidden; color: var(--accent-soft); font-size: .73rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.priority { display: inline-flex; align-items: center; width: fit-content; color: var(--muted); font-size: .72rem; font-weight: 750; }
.priority::before { width: .45rem; height: .45rem; margin-right: .35rem; border-radius: 50%; background: var(--line); content: ""; }
.priority.high::before { background: var(--accent); }
.priority.urgent { color: var(--danger); }
.priority.urgent::before { background: var(--danger); box-shadow: 0 0 0 3px rgba(241, 140, 130, .12); }

.admin-list { display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: .65rem; }
.admin-list-head, .admin-list-row { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(90px, .8fr) minmax(90px, .7fr) minmax(80px, .6fr) minmax(120px, .9fr); gap: .8rem; align-items: center; }
.admin-list-head { padding: .55rem .8rem; color: var(--muted); background: #0e191e; font-size: .72rem; font-weight: 750; }
.admin-list-row { width: 100%; min-height: 0; padding: .75rem .8rem; text-align: left; color: var(--ink); border: 0; border-top: 1px solid var(--line); border-radius: 0; background: var(--surface); }
.admin-list-row:hover, .admin-list-row.selected { background: #20353b; }
.admin-list-subject { display: grid; min-width: 0; gap: .2rem; }
.admin-list-subject strong, .admin-list-subject small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-list-subject small, .admin-list-row time { color: var(--muted); font-size: .72rem; font-weight: 500; }
.admin-detail { max-height: calc(100vh - 2rem); overflow: auto; }
.admin-detail .panel-head { align-items: flex-start; }
.admin-detail .panel-head button { flex: 0 0 auto; min-height: 2.3rem; padding: .35rem .65rem; white-space: nowrap; }
.admin-detail h2 { font-size: clamp(1.4rem, 2vw, 1.8rem); overflow-wrap: anywhere; }
.github-sync { display: grid; gap: .7rem; margin: 1rem 0 1.3rem; padding: .85rem; border: 1px solid var(--line); border-radius: .65rem; background: #0e191e; }
.github-sync-head { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.github-sync-head h3 { margin: 0; font-family: inherit; font-size: .92rem; font-weight: 800; }
.github-sync-list { display: grid; gap: .55rem; }
.github-sync-row { display: grid; gap: .3rem; padding: .65rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--surface); }
.github-sync-row.retry { border-color: rgba(241, 140, 130, .45); }
.github-sync-summary { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.github-sync-row small { color: var(--muted); }
.github-sync-error { margin: .2rem 0 0; color: var(--danger); font-size: .78rem; line-height: 1.5; overflow-wrap: anywhere; }
.badge.sync-processing, .badge.sync-pending { color: var(--accent-soft); border-color: rgba(231, 166, 75, .4); }
.badge.sync-retry { color: var(--danger); border-color: rgba(241, 140, 130, .4); }
.badge.sync-done { color: var(--success); border-color: rgba(127, 201, 164, .4); }
.inline-form { display: flex; flex-wrap: wrap; gap: .7rem; align-items: end; }
.inline-form label { flex: 1 1 150px; }
.empty { padding: 2rem; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: .6rem; }

footer { display: flex; justify-content: space-between; width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem 0 2.5rem; color: var(--muted); border-top: 1px solid var(--line); font-size: .82rem; }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 10; max-width: min(28rem, calc(100% - 2rem)); padding: .85rem 1rem; border: 1px solid var(--line); border-radius: .55rem; background: #24353a; box-shadow: 0 10px 40px #0008; opacity: 0; transform: translateY(.5rem); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 760px) {
  main { padding-top: 3rem; }
  .site-header { align-items: flex-start; }
  nav { flex-wrap: wrap; justify-content: flex-end; }
  h1 { font-size: clamp(2.6rem, 13vw, 4.2rem); }
  .field-grid, .admin-workspace.has-detail { grid-template-columns: 1fr; }
  .admin-queue-head { display: grid; align-items: start; }
  .admin-queue-head .view-switch { width: 100%; }
  .queue-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kanban-board { min-width: 900px; }
  .admin-list { overflow: visible; border: 0; gap: .55rem; }
  .admin-list-head { display: none; }
  .admin-list-row { grid-template-columns: minmax(0, 1fr) auto auto; border: 1px solid var(--line); border-radius: .55rem; }
  .admin-list-row > :nth-child(2), .admin-list-row > :nth-child(5) { display: none; }
  .admin-detail { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
