:root {
  --accent: #1f6a4d;
  --accent-deep: #123f2e;
  --accent-soft: #e7f1e8;
  --gold: #8a6708;
  --surface: #ffffff;
  --surface-soft: #f3f6f2;
  --surface-strong: #e4ebe1;
  --text: #1c231d;
  --muted: #5b6a58;
  --line: #d9e2d5;
  --danger: #a83f42;
  --danger-soft: #fbf1ef;
  --shadow: 0 16px 40px rgba(16, 32, 22, .12);
  --shadow-soft: 0 4px 14px rgba(16, 32, 22, .07);
  --header-height: 64px;
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: #f5f7f3;
  padding-top: var(--header-height);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
html.largeText { font-size: 112%; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-deep); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(31, 106, 77, .35);
  outline-offset: 2px;
}

.labIcon {
  width: 20px;
  height: 20px;
  display: block;
  flex: 0 0 auto;
  color: currentColor;
}
.iconPair { display: inline-flex; align-items: center; gap: 1px; }
.iconPair .labIcon { width: 16px; height: 16px; }
.chevronUp { transform: rotate(180deg); }

.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.orientationNotice {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(38, 36, 50, .96);
  color: white;
}

.siteHeader {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1000;
  min-height: var(--header-height);
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 14px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  transition: transform .2s ease;
}
.siteHeader.isHidden { transform: translateY(-100%); }
.appIdentity {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: left;
}
.appIdentity img { width: 36px; height: 36px; object-fit: contain; }
.appIdentity strong { display: block; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appIdentity small { display: block; margin-top: 2px; color: var(--muted); }
.headerActions { display: flex; align-items: center; gap: 2px; }
.iconButton {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 1.45rem;
}
.iconButton:hover { background: var(--surface-soft); }
.iconButton[aria-expanded="true"] { background: var(--surface-strong); color: var(--accent-deep); }

.appShell {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px;
}
.operationDisclosure {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.5;
}

.workspace {
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: minmax(280px, 370px) minmax(0, 1fr);
  gap: 14px;
}
.libraryPanel, .detailPanel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.libraryPanel {
  padding: 16px;
  align-self: start;
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 100px);
  overflow: auto;
}
.detailPanel { padding: 22px; min-height: 560px; }
.panelHeader, .detailHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.panelHeader h1, .detailHeader h2 { margin: 0; }
.launcherHeading { min-width: 0; display: flex; align-items: center; gap: 9px; }
.launcherHeading img { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px; object-fit: contain; }
.launcherHeading h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.25rem; }
.panelPrimaryActions { display: flex; align-items: center; gap: 8px; }
.panelIconButton {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  background: white;
  color: var(--accent-deep);
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 800;
}
.panelIconButton:hover { background: var(--surface-soft); box-shadow: var(--shadow-soft); }
.panelIconButton:active { transform: translateY(1px); }
.panelIconButton.active { background: var(--accent-deep); border-color: var(--accent-deep); color: white; }
.primaryIconButton { background: var(--accent); border-color: var(--accent); color: white; }
.primaryIconButton:hover { background: var(--accent-deep); }
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-deep);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* Collapsible search & recent panel, opened from the library panel search button */
.searchPanel {
  margin: 14px 0 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.searchField { display: block; margin: 0 0 10px; }
.searchField input, .modalDialog input, .modalDialog textarea, .modalDialog select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: white;
  color: var(--text);
}
.modalDialog textarea { resize: vertical; }
.listOptions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .85rem;
}
.listOptionButtons { display: flex; align-items: center; gap: 10px; }
.textButton {
  border: 0;
  padding: 4px;
  color: var(--accent-deep);
  background: transparent;
  cursor: pointer;
}
.textButton[aria-pressed="true"] { font-weight: 700; text-decoration: underline; }
.textButton:disabled { color: var(--muted); text-decoration: none; cursor: not-allowed; opacity: .6; }
.recentSection h2 { margin: 16px 0 8px; font-size: .9rem; }

/* Grouped list: お気に入り → URLリンク → コピーしてURLリンクを開く → コピー用テキスト */
.itemGroup { margin-top: 16px; }
.itemGroup:first-of-type { margin-top: 12px; }
.groupHeading {
  margin: 0 0 8px;
  color: var(--accent-deep);
  font-size: .84rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.itemList { display: grid; gap: 6px; }
.itemList.compact { margin-bottom: 14px; }
.itemCard {
  width: 100%;
  display: flex;
  align-items: stretch;
  border: 1px solid transparent;
  border-radius: 13px;
  background: var(--surface-soft);
  color: var(--text);
  overflow: hidden;
  transition: border-color .15s ease, background .15s ease, opacity .15s ease, transform .15s ease;
}
.itemCard:hover { border-color: var(--line); box-shadow: var(--shadow-soft); }
.itemCard.isSelected { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--shadow-soft); }
.itemMainAction {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 48px;
  border: 0;
  padding: 8px 9px;
  text-align: left;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.itemMainAction:hover { background: rgba(255, 255, 255, .55); }
.itemMainStatic {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 22px 28px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 8px 9px;
}
.itemIcon { min-width: 28px; display: inline-flex; align-items: center; justify-content: center; color: var(--accent-deep); text-align: center; white-space: nowrap; }
.itemIcon > .labIcon { width: 18px; height: 18px; }
.itemText { min-width: 0; display: grid; gap: 2px; }
.itemTitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: .93rem; }
.itemSavedAt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .75rem; font-weight: 400; }
.itemFavoriteButton {
  flex: 0 0 44px;
  min-width: 44px;
  min-height: 48px;
  border: 0;
  border-left: 1px solid var(--line);
  padding: 0;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  font-size: 1.2rem;
}
.itemFavoriteButton:hover { background: rgba(255, 255, 255, .7); }
.itemEdit {
  flex: 0 0 auto;
  min-width: 52px;
  min-height: 48px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 0;
  border-left: 1px solid var(--line);
  padding: 5px 7px;
  background: var(--surface-strong);
  color: var(--accent-deep);
  cursor: pointer;
  font-size: .9rem;
}
.itemEdit small { font-size: .75rem; font-weight: 700; }
.itemEdit:hover { background: var(--accent); color: white; }
.dragHandle { color: var(--muted); cursor: grab; display: inline-flex; align-items: center; justify-content: center; }
.reorderControls { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; padding: 5px 6px; border-left: 1px solid var(--line); }
.moveButton {
  width: 34px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--accent-deep);
  cursor: pointer;
  font-size: .72rem;
}
.moveButton:hover { background: var(--accent); color: white; }
.itemCard.isReordering { cursor: grab; }
.itemCard.isDragging { opacity: .45; transform: scale(.985); }
.itemCard.isDropTarget { border-color: var(--accent); box-shadow: inset 0 0 0 2px rgba(31, 106, 77, .18); }
.emptyState, .welcomePanel {
  text-align: center;
  color: var(--muted);
}
.emptyState { padding: 24px 10px; }
.welcomePanel { max-width: 520px; margin: 90px auto 0; }
.welcomePanel img { width: 82px; height: 82px; }
.welcomePanel h2 { color: var(--text); }

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 700;
}
.button.primary { background: var(--accent); color: white; box-shadow: 0 2px 8px rgba(18, 63, 46, .22); transition: background .15s ease, box-shadow .15s ease, transform .1s ease; }
.button.primary:hover { background: var(--accent-deep); box-shadow: 0 4px 14px rgba(18, 63, 46, .28); }
.button.primary:active { transform: translateY(1px); }
.button.secondary { border-color: var(--line); background: white; color: var(--text); }
.button.secondary:hover { background: var(--surface-soft); }
.button.danger { border-color: #e8c8c8; background: var(--danger-soft); color: var(--danger); }

.favoriteButton {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--gold);
  cursor: pointer;
  font-size: 1.3rem;
}
.detailSummary { color: var(--muted); line-height: 1.7; }
.linkArea { margin-top: 18px; }
.detailLinkCard {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 13px;
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
}
.detailLinkCard:hover { border-color: var(--accent); background: var(--accent-soft); }
.detailLinkIcon { flex: 0 0 auto; color: var(--accent-deep); }
.detailLinkIcon .labIcon { width: 22px; height: 22px; }
.detailLinkText { min-width: 0; display: grid; gap: 3px; }
.detailLinkText strong { color: var(--accent-deep); }
.detailLinkText small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* Compact icon actions: copy / open / copy&open / edit / delete */
.detailActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.iconAction {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 58px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 8px;
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}
.iconAction small { font-size: .75rem; font-weight: 700; color: var(--muted); }
.iconAction:hover { background: var(--surface-soft); }
.iconAction.accent { background: var(--surface-strong); border-color: var(--line); color: var(--accent-deep); }
.iconAction.accent:hover { background: var(--accent-soft); }
.iconAction.danger { border-color: #e8c8c8; color: var(--danger); }
.iconAction.danger:hover { background: var(--danger-soft); }
.iconAction.danger small { color: var(--danger); opacity: .8; }
.promptHint { margin: 12px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.6; }
.detailFooter {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .8rem;
}

.bottomBar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 1100;
  height: calc(52px + env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 5px 14px env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.bottomAction {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 8px 14px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
.bottomAction:hover { background: var(--surface-soft); }
.shareAction {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
}
.shareAction:hover { background: var(--accent-deep); color: white; }
.compactAction { min-width: 54px; display: inline-grid; place-items: center; border: 1px solid var(--line); }
.fontSizeIcon { width: 25px; height: 25px; }
.shareMenu {
  position: fixed;
  z-index: 1200;
  left: 14px;
  bottom: calc(60px + env(safe-area-inset-bottom));
  width: min(330px, calc(100vw - 28px));
  max-height: min(470px, calc(100vh - 100px));
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  box-shadow: var(--shadow);
}
.shareMenu button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  background: transparent;
  cursor: pointer;
}
.shareMenu button:hover { background: var(--surface-soft); }
.shareMenu .supportMenuItem { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; color: var(--accent-deep); font-weight: 700; }

.menuStatus { margin-bottom: 12px; }
.menuStatus strong { display: block; }
.menuStatus span { display: block; margin-top: 3px; color: var(--muted); font-size: .82rem; }
.menuGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.menuGridButton {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 700;
  font-size: .82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.menuGridButton:hover { background: var(--surface-strong); }
.modalDialog {
  width: min(760px, calc(100vw - 24px));
  max-height: min(90vh, 860px);
  overflow: auto;
  border: 0;
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.modalDialog::backdrop { background: rgba(30, 27, 42, .55); }
.modalDialog.isFallbackOpen {
  position: fixed;
  z-index: 3500;
  inset: 50% auto auto 50%;
  display: block;
  transform: translate(-50%, -50%);
  margin: 0;
  background: #fff;
}
body.modalOpen::before {
  content: "";
  position: fixed;
  z-index: 3400;
  inset: 0;
  background: rgba(30, 27, 42, .55);
}
body.modalOpen { overflow: hidden; }
.compactDialog { width: min(620px, calc(100vw - 24px)); }
.modalHeader { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modalHeader h2 { margin: 0; }
.editorHeaderActions { display: flex; align-items: center; gap: 4px; }
.modalDialog form { display: grid; gap: 14px; }
.modalDialog label { display: grid; gap: 6px; font-weight: 700; }
.modalActions { display: flex; justify-content: flex-end; gap: 10px; }
#deleteInEditorButton { margin-right: auto; }
.suggestionRow { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--muted); }
.privacyNote, .smallText { color: var(--muted); font-size: .84rem; line-height: 1.6; }
.modalBody h3 { margin-bottom: 6px; }
.modalBody p { line-height: 1.7; }
.installActions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.installActions .button { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }
.metaList { display: grid; gap: 6px; }
.metaList div { display: grid; grid-template-columns: 100px 1fr; gap: 12px; }
.metaList dt { font-weight: 700; }
.metaList dd { margin: 0; }
.toast {
  position: fixed;
  z-index: 4000;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 24px);
  padding: 11px 16px;
  border-radius: 12px;
  background: #2d2a39;
  color: white;
  box-shadow: var(--shadow);
}
.pendingOpenPanel {
  position: fixed;
  z-index: 1300;
  left: 50%;
  bottom: calc(66px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 44px;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  box-shadow: var(--shadow);
}
.pendingOpenMessage { min-width: 0; display: grid; gap: 3px; }
.pendingOpenMessage span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .82rem; }
.pendingOpenButton { min-height: 48px; }
.pendingOpenClose { width: 44px; height: 44px; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .libraryPanel { position: static; max-height: none; }
  .detailPanel { min-height: 420px; }
  .welcomePanel { margin-top: 50px; }
}

@media (max-width: 620px) {
  :root { --header-height: 62px; }
  .appShell { padding: 12px; }
  .appIdentity strong { font-size: .93rem; }
  .panelHeader { align-items: flex-end; }
  .panelPrimaryActions { gap: 5px; }
  .panelIconButton { width: 42px; height: 42px; }
  .detailPanel { padding: 16px; }
  .detailHeader { align-items: flex-start; }
  .detailActions { gap: 6px; }
  .iconAction { min-width: 50px; min-height: 48px; padding: 5px 4px; font-size: 1rem; }
  .shareMenu { width: calc(100vw - 24px); left: 12px; }
  .modalActions { flex-wrap: wrap; }
  .modalActions .button { flex: 1 1 auto; min-width: 100px; }
  .pendingOpenPanel {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
  }
  .pendingOpenButton { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .pendingOpenClose { grid-column: 2; grid-row: 1; }
}

@media (orientation: landscape) and (max-width: 767px) {
  .orientationNotice { display: flex; }
}

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