:root {
  color-scheme:light;
  --ground:#edf2f2;
  --surface:#fff;
  --raised:#f4f6f6;
  --active:#e7eded;
  --border:#e3e8e8;
  --text:#182123;
  --muted:#58666a;
  --accent:#1b6c80;
  --negative:#ae2737;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Hiragino Kaku Gothic ProN","Yu Gothic",Meiryo,Arial,sans-serif;
  color:var(--text);
  font-size:16px;
  font-synthesis:none;
}
* {
  box-sizing:border-box;
}
html,body {
  margin:0;
  min-height:100%;
  max-width:100%;
  overflow-x:clip;
}
body {
  background:var(--ground);
  padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button,input,select,textarea {
  font:inherit;
  color:inherit;
}
button,a,input,select,textarea {
  -webkit-tap-highlight-color:transparent;
}
button,a {
  touch-action:manipulation;
}
button {
  min-height:44px;
  min-width:44px;
  border:1px solid #cbd4d5;
  border-radius:6px;
  background:#fff;
  padding:9px 14px;
  cursor:pointer;
  font-weight:550;
  line-height:1.4;
}
button:hover {
  background:#edf2f2;
}
button:active {
  transform:translateY(1px);
}
button:disabled {
  opacity:.5;
  cursor:wait;
}
button.primary {
  background:#182a2e;
  color:#fff;
  border-color:#182a2e;
}
button.primary:hover {
  background:#30474c;
}
.quiet {
  background:transparent;
  border-color:transparent;
}
.danger {
  color:var(--negative);
}
a {
  color:inherit;
  text-decoration:none;
}
a:hover {
  text-decoration:underline;
}
a.back-link {
  display:inline-flex;
  align-items:center;
  min-height:44px;
  color:var(--muted);
}
:focus-visible {
  outline:3px solid var(--accent);
  outline-offset:3px;
}
h1 {
  font-size:24px;
  line-height:1.35;
  overflow-wrap:anywhere;
  margin:0;
  font-weight:650;
}
h2 {
  font-size:18px;
  line-height:1.4;
  margin:0 0 12px;
  font-weight:650;
}
h3 {
  font-size:16px;
  line-height:1.4;
}
p {
  line-height:1.6;
  overflow-wrap:anywhere;
  margin:8px 0 16px;
}
small {
  font-size:13px;
  color:var(--muted);
}
.muted {
  color:var(--muted);
}
#header {
  min-height:64px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:8px 24px;
}
.brand {
  flex-shrink:0;
}
.brand-name {
  display:flex;
  align-items:center;
  gap:9px;
  font-size:20px;
  font-weight:700;
  white-space:nowrap;
}
.header-actions {
  display:flex;
  align-items:center;
  min-width:0;
  gap:4px;
}
.account {
  max-width:360px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#app {
  background:var(--surface);
  min-height:calc(100dvh - 72px);
  margin:0 8px 8px;
  border-radius:16px;
  border:1px solid var(--border);
  overflow:hidden;
}
.page {
  padding:24px;
  max-width:1600px;
  margin:auto;
}
.title-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
  margin-bottom:20px;
}
.actions {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:8px;
}
.actions p {
  margin:0;
}
.project-list {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(min(100%,320px),1fr));
  gap:24px;
}
.project-card {
  padding:24px;
  border:1px solid var(--border);
  border-radius:8px;
  min-width:0;
}
.project-card h2 {
  font-size:22px;
  overflow-wrap:anywhere;
}
.metrics {
  display:flex;
  gap:24px;
  margin:20px 0;
  font-variant-numeric:tabular-nums;
}
.project-link {
  display:block;
  min-height:44px;
}
.empty {
  padding:32px 20px;
  background:var(--raised);
  border-radius:8px;
}
.empty h2 {
  margin-top:0;
}
.tabs {
  display:flex;
  gap:20px;
  margin:20px 0;
  border-bottom:1px solid var(--border);
  overflow:auto;
}
.tabs button {
  border:0;
  border-radius:0;
  background:transparent;
  white-space:nowrap;
  padding:12px 0;
}
.tabs .selected {
  border-bottom:2px solid var(--text);
}
.drawing-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));
  gap:24px;
}
.drawing-card {
  border:1px solid var(--border);
  border-radius:8px;
  overflow:hidden;
  min-width:0;
}
.drawing-thumb {
  display:block;
  width:100%;
  height:180px;
  object-fit:contain;
  background:var(--raised);
}
.drawing-info {
  padding:20px;
}
.drawing-info h2 {
  overflow-wrap:anywhere;
}
.notice {
  background:#fff4d8;
  color:#694709;
  padding:16px;
  border-radius:6px;
}
.field {
  display:flex;
  flex-direction:column;
  gap:7px;
  min-width:0;
  margin:0 0 16px;
  font-size:14px;
  font-weight:550;
}
.field input,.field select,.field textarea {
  width:100%;
  min-width:0;
  font-size:16px;
  font-weight:400;
}
.field textarea {
  resize:vertical;
}
.field>span {
  line-height:1.5;
}
input,textarea,select {
  min-height:44px;
  border:1px solid #cbd4d5;
  border-radius:6px;
  background:#fff;
  padding:10px 12px;
  max-width:100%;
}
input[type=color] {
  padding:5px;
  min-width:80px;
}
input[type=checkbox] {
  min-height:24px;
  width:24px;
}
.form-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:0 16px;
}
.form-grid .full {
  grid-column:1/-1;
}
.login-screen {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:64px;
  max-width:1040px;
  padding:64px 24px;
  margin:auto;
  align-items:start;
}
.login-intro h1 {
  font-size:30px;
  margin:0 0 24px;
}
.login-card {
  background:var(--raised);
  padding:28px;
  border-radius:8px;
}
.login-card h2 {
  font-size:22px;
}
.login-form {
  margin-top:24px;
}
.login-form button {
  width:100%;
}
dialog {
  color:var(--text);
  width:min(94vw,560px);
  max-width:94vw;
  max-height:90dvh;
  padding:0;
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
  box-shadow:0 12px 40px #0003;
}
dialog.wide {
  width:min(94vw,900px);
}
dialog::backdrop {
  background:#182a2e66;
}
.modal-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:16px 20px;
  border-bottom:1px solid var(--border);
  position:sticky;
  top:0;
  background:#fff;
  z-index:2;
}
.modal-head h2 {
  margin:0;
  font-size:19px;
}
.modal-body {
  padding:20px;
  min-width:0;
}
.menu-list {
  display:flex;
  flex-direction:column;
  gap:8px;
}
.menu-list button {
  text-align:left;
}
.manage-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:16px 0;
  border-bottom:1px solid var(--border);
  overflow-wrap:anywhere;
}
.manage-row>div {
  min-width:0;
}
.manage-row p {
  margin-bottom:0;
}
.swatch {
  display:inline-block;
  width:13px;
  height:13px;
  border-radius:50%;
  margin-right:9px;
  flex-shrink:0;
}
.legend-list {
  display:grid;
  gap:16px;
}
.legend-list>div {
  line-height:1.5;
}
.table-wrap {
  max-width:100%;
  overflow:auto;
  margin:16px 0 24px;
  overscroll-behavior-x:contain;
}
table {
  border-collapse:collapse;
  width:100%;
  font-size:14px;
  font-variant-numeric:tabular-nums;
}
th,td {
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  white-space:nowrap;
  text-align:left;
}
th {
  color:var(--muted);
  font-weight:550;
}
th button {
  border:0;
  background:transparent;
  padding:4px;
  min-width:44px;
}
td.num,th.num {
  text-align:right;
}
.table-wrap td:first-child {
  position:sticky;
  left:0;
  background:#fff;
}
.table-wrap tbody tr:hover td {
  background:var(--raised);
}
.table-wrap tr[tabindex] {
  cursor:pointer;
}
.filter-chips {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
.filter-chips button[aria-pressed=true] {
  background:var(--active);
  border-color:var(--text);
}
.drawing-workspace {
  display:grid;
  grid-template-columns:minmax(0,1fr) 380px;
  height:calc(100dvh - 74px);
  min-height:420px;
}
.drawing-main {
  min-width:0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.drawing-heading {
  padding:12px 16px;
  display:flex;
  align-items:center;
  gap:16px;
  flex-wrap:wrap;
}
.drawing-heading a {
  max-width:36%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  min-height:44px;
  display:inline-flex;
  align-items:center;
  color:var(--muted);
  font-size:14px;
}
.drawing-heading h1 {
  font-size:18px;
  flex:1;
}
.viewer-toolbar {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  padding:8px 12px;
  background:var(--raised);
  align-items:center;
}
.viewer-toolbar .field {
  margin:0;
  flex-direction:row;
  align-items:center;
  gap:6px;
}
.viewer-toolbar .field span {
  display:none;
}
.viewer-toolbar select {
  max-width:110px;
}
.viewer-toolbar button {
  padding:8px 10px;
  font-size:14px;
}
.viewer-info {
  font-size:12px;
  display:flex;
  gap:12px;
  justify-content:space-between;
  padding:6px 16px;
  min-height:28px;
}
.mode-hint {
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.canvas-host {
  flex:1;
  min-height:200px;
  min-width:0;
}
.detail-panel {
  border-left:1px solid var(--border);
  background:#fff;
  overflow:auto;
  min-width:0;
}
.panel-head {
  position:sticky;
  top:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 16px;
  background:#fff;
  z-index:3;
  border-bottom:1px solid var(--border);
}
.panel-head h2 {
  font-size:16px;
  margin:0;
}
.detail-body {
  padding:16px;
  overflow-wrap:anywhere;
}
.detail-body dl {
  margin:0;
}
.detail-body dd {
  margin-left:0;
}
.detail-body img {
  max-width:100%;
}
.marker-form {
  display:grid;
  gap:16px;
}
.marker-form fieldset {
  margin:0;
  min-width:0;
  border:1px solid var(--border);
  border-radius:6px;
  padding:12px;
}
.marker-fields {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:0 14px;
}
.marker-fields .field-wide {
  grid-column:1/-1;
}
.marker-types {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
.marker-type {
  border:2px solid var(--border);
  text-align:left;
}
.marker-type[aria-pressed=true] {
  border-color:var(--text);
  background:var(--raised);
}
.marker-photo-grid,.photo-grid {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:8px;
}
.marker-photo-grid img,.photo-grid img {
  width:100%;
  height:100px;
  object-fit:cover;
}
.marker-photo-grid button,.photo-grid button {
  padding:0;
  min-width:0;
  overflow:hidden;
}
.marker-gallery img {
  max-width:100%;
  max-height:65dvh;
  object-fit:contain;
}
.marker-detail-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}
.marker-detail-grid dt {
  font-size:12px;
  color:var(--muted);
}
.marker-comment {
  background:var(--raised);
  padding:12px;
  margin-bottom:12px;
  border-radius:6px;
}
.marker-comment p {
  white-space:pre-wrap;
}
.marker-audit {
  font-size:13px;
  color:var(--muted);
}
#toasts {
  position:fixed;
  bottom:max(16px,env(safe-area-inset-bottom));
  left:50%;
  transform:translateX(-50%);
  width:min(92vw,560px);
  display:grid;
  gap:8px;
  z-index:10000;
  pointer-events:none;
}
.toast {
  background:#182a2e;
  color:#fff;
  padding:14px 18px;
  border-radius:8px;
  line-height:1.5;
  box-shadow:none;
}
.toast.error {
  background:#842534;
}
.busy {
  position:fixed;
  inset:0;
  z-index:1000;
  background:#fff9;
  display:grid;
  place-items:center;
  padding:24px;
}
.busy>div {
  padding:20px;
  background:#182a2e;
  color:#fff;
  border-radius:8px;
}
.num {
  font-variant-numeric:tabular-nums;
}
@media(max-width:899px) {
  #header {
    padding:8px 16px;
    min-height:60px;
  }
  .brand-name {
    font-size:18px;
  }
  .brand-name img {
    width:26px;
    height:26px;
  }
  .account {
    max-width:190px;
    font-size:13px;
    padding:8px;
  }
  .header-actions {
    gap:0;
  }
  #app {
    margin:0;
    border:0;
    border-radius:0;
    min-height:calc(100dvh - 60px);
  }
  .page {
    padding:20px 16px;
  }
  .title-row {
    align-items:flex-start;
  }
  .title-row>.actions {
    width:100%;
  }
  .title-row>.actions button {
    flex:1;
  }
  .drawing-workspace {
    display:block;
    height:calc(100dvh - 60px);
    min-height:400px;
  }
  .drawing-main {
    height:100%;
  }
  .detail-panel {
    display:none;
    position:fixed;
    bottom:0;
    left:0;
    right:0;
    max-height:85dvh;
    border:1px solid var(--border);
    border-bottom:0;
    border-radius:16px 16px 0 0;
    z-index:20;
    box-shadow:0 -8px 32px #0002;
    overflow-y:auto;
    padding-bottom:env(safe-area-inset-bottom);
  }
  .detail-panel.open {
    display:block;
  }
  .panel-head {
    padding:12px 20px;
  }
  .detail-body {
    padding:16px 20px;
  }
  .viewer-toolbar {
    gap:4px;
  }
  .viewer-toolbar button {
    font-size:13px;
    padding:8px;
  }
  .drawing-heading {
    padding:4px 12px;
    gap:12px;
  }
  .drawing-heading h1 {
    font-size:16px;
  }
  .viewer-info {
    padding:6px 12px;
  }
  .login-screen {
    gap:24px;
    padding:28px 20px;
    grid-template-columns:1fr;
  }
  .login-intro h1 {
    font-size:26px;
    margin:0 0 16px;
  }
  .login-intro p {
    margin-bottom:12px;
  }
  .login-card {
    padding:20px;
  }
  .login-intro>.muted {
    font-size:14px;
  }
  .manage-row {
    flex-wrap:wrap;
  }
  .project-list,.drawing-grid {
    gap:16px;
  }
  .marker-photo-grid,.photo-grid {
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
  dialog {
    max-height:90dvh;
  }
  .form-grid {
    gap:0 12px;
  }
}
@media(max-width:420px) {
  #header {
    gap:4px;
    padding:8px 10px;
  }
  .brand-name {
    font-size:17px;
    gap:5px;
  }
  .brand-name img {
    width:24px;
    height:24px;
  }
  .account {
    max-width:130px;
    font-size:12px;
  }
  .header-actions>button {
    padding:8px;
    min-width:44px;
  }
  .mode-hint {
    max-width:52%;
  }
  .modal-body {
    padding:16px;
  }
  .marker-fields {
    grid-template-columns:1fr;
  }
  .marker-fields .field-wide {
    grid-column:auto;
  }
  .project-card {
    padding:20px;
  }
  .form-grid {
    grid-template-columns:1fr;
  }
  .viewer-toolbar {
    padding:6px;
  }
  .viewer-toolbar select {
    max-width:82px;
  }
}
.type-dot {
  display:inline-block;
  width:12px;
  height:12px;
  border-radius:50%;
  margin-right:7px;
  flex:none;
}
.type-chip {
  display:inline-flex;
  align-items:center;
  text-align:left;
}
.type-chip.selected {
  background:var(--active);
  border-color:var(--text);
}
@media(prefers-reduced-motion:reduce) {
  *,*::before,*::after {
    scroll-behavior:auto!important;
    transition:none!important;
    animation:none!important;
  }
}

/* Viewer controls keep their desktop layout; compact controls live at the mobile edge. */
.toolbar-mobile,.sheet-handle { display:none; }
@media(min-width:900px) {
  .viewer-toolbar .add-pin[aria-pressed=true] { background:#182a2e; color:#fff; border-color:#182a2e; }
}
.placement-banner {
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:6px 12px; background:#fff4d8; color:#493309; font-size:14px;
}
.placement-banner[hidden] { display:none; }
.placement-banner button { flex:none; }
.pdf-pin.selected-pin svg { outline:2px solid #182a2e; outline-offset:3px; border-radius:50%; }
.drawing-thumb { aspect-ratio:16/10; }
.marker-photo-grid img,.photo-grid img,.marker-photo-tile img { aspect-ratio:1; }
.marker-gallery img { aspect-ratio:4/3; }
p:lang(ja),textarea:lang(ja),.marker-comment:lang(ja),.detail-body dd:lang(ja) { line-break:strict; }
.form-error { color:var(--negative); }
.field-error { margin:0; font-size:14px; font-weight:400; }
[aria-invalid=true] { border-color:var(--negative); }
.type-grid[aria-invalid=true] { outline:2px solid var(--negative); outline-offset:3px; }
@media(max-width:899px) {
  .drawing-workspace { min-height:0; }
  .drawing-main { padding-bottom:calc(64px + env(safe-area-inset-bottom)); position:relative; }
  .canvas-host { min-height:0; }
  .viewer-toolbar {
    position:fixed; inset:auto 0 0; z-index:15;
    display:flex; flex-wrap:nowrap; justify-content:space-between; gap:3px;
    padding:6px max(6px,env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left));
    border-top:1px solid var(--border); background:#f4f6f6;
    max-width:100%;
  }
  .viewer-toolbar .field { flex:0 1 48px; width:48px; min-width:44px; }
  .viewer-toolbar select { width:100%; min-width:44px; max-width:100%; padding:8px 2px; font-size:16px; }
  .viewer-toolbar button {
    flex:1 1 44px; min-width:44px; min-height:52px; max-width:88px;
    padding:3px 2px; font-size:11px; white-space:nowrap;
  }
  .viewer-toolbar .toolbar-desktop { display:none; }
  .toolbar-mobile { display:flex; flex-direction:column; align-items:center; justify-content:center; line-height:1.2; gap:1px; }
  .toolbar-icon { font-size:21px; line-height:24px; }
  .viewer-toolbar .add-pin { background:#182a2e; color:#fff; border-color:#182a2e; flex-grow:1.3; }
  .viewer-toolbar .add-pin[aria-pressed=true] { background:#1b6c80; border-color:#1b6c80; outline:2px solid #182a2e; outline-offset:1px; }
  .detail-panel { height:50dvh; max-height:85dvh; overflow:hidden; }
  .detail-panel.open { display:flex; flex-direction:column; }
  .detail-panel.expanded { height:85dvh; }
  .sheet-handle {
    display:flex; align-items:center; justify-content:center; width:100%; min-height:44px;
    flex:none; padding:0; border:0; background:#fff; border-radius:16px 16px 0 0;
    touch-action:none; cursor:ns-resize;
  }
  .sheet-handle>span { width:40px; height:5px; border-radius:3px; background:#7c898c; }
  .panel-head { flex:none; }
  .detail-body { flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain; }
  dialog:has(.marker-form) { max-height:88dvh; padding-bottom:env(safe-area-inset-bottom); }
  #toasts { bottom:calc(76px + env(safe-area-inset-bottom)); }
}

.update-toast { display:flex; align-items:center; justify-content:space-between; gap:12px; pointer-events:auto; }
.update-toast button { flex:none; }
