/* Project identity and actions occupy separate header rows. */
.shell>main{grid-template-rows:auto minmax(0,1fr) auto}
.shell>main>header{height:auto;min-height:78px;padding-top:10px;padding-bottom:10px}
.shell>main>header .chat-heading{gap:7px;min-width:0}
.chat-title-line{display:flex;align-items:baseline;gap:6px;min-width:0;flex-wrap:wrap}
.chat-title-line #title{max-width:100%}
.chat-title-line .site-link{display:inline;max-width:100%;font-size:12px;overflow-wrap:anywhere;white-space:normal}
.chat-title-line .site-link[hidden]{display:none}
.chat-title-line .site-link::before{content:none}
.chat-title-line #threadLabel{font-size:12px;overflow-wrap:anywhere;white-space:normal}
.chat-title-line #threadLabel::before{content:'- ';color:#797775}
.chat-title-line .session-id-label{min-width:0;font-size:10px;font-weight:400;line-height:1.5;color:#788391;overflow-wrap:anywhere;white-space:normal;user-select:all;cursor:text}
.chat-title-line .session-id-label[hidden]{display:none}
.shell>main>header .header-context{max-width:100%;overflow-x:auto;overflow-y:hidden;gap:6px;padding:2px 0;scrollbar-width:thin}
.header-context .editor-link{margin-left:0;min-height:26px}
@media(max-width:760px){
 .shell>main>header{display:grid;grid-template-columns:minmax(0,1fr) 112px;gap:7px 10px}
 .shell>main>header .chat-heading{display:contents}
 .chat-title-line{grid-column:1/-1}
 .shell>main>header .chat-title-line #title,.shell>main>header .chat-title-line #threadLabel{white-space:normal}
 .shell>main>header .header-context{grid-column:1/-1;grid-row:3;flex-wrap:wrap;overflow:visible}
 .shell>main>header .session-usage{grid-column:2;grid-row:2;width:112px}
 .shell>main>header #state{display:none}
}

#openProjectRules { border-color:#d0d5dd; background:#f2f4f7; color:#344054; }
#openProjectRules:hover { background:#e4e7ec; }
#openProjectRules.has-rules { border-color:#b3d6bd; background:#e8f6ec; color:#1c6331; }
#openProjectRules.has-rules:hover { background:#d8efde; }
.project-rules-modal {
  width:min(900px, calc(100vw - 48px)); height:min(780px, calc(100dvh - 48px));
  max-width:none; max-height:none; margin:auto; padding:0; overflow:hidden;
  border-radius:12px; box-shadow:0 18px 56px #15243a33;
}
.project-rules-modal[open] { display:grid; grid-template-rows:auto auto minmax(0, 1fr); }
.account-rules-modal[open] { grid-template-rows:auto minmax(0, 1fr); }
.project-rules-modal > header {
  height:auto; margin:0; padding:15px 20px; background:#fff;
  border-bottom:1px solid #e1e7ef; box-shadow:none;
}
#projectRulesTitle, #accountRulesTitle { font-size:18px; color:#233247; }
#projectRulesProject { margin:0; color:#5b6777; font-size:13px; overflow-wrap:anywhere; }
.project-rules-modal > header > button {
  flex:0 0 auto; display:grid; place-items:center; width:36px; height:36px;
  padding:0; border:1px solid #dce3eb; border-radius:6px; color:#344054; line-height:1;
}
.project-rules-modal > header > button:hover { background:#f2f4f7; }
.project-rules-tabs {
  display:flex; gap:4px; padding:0 20px; border-bottom:1px solid #e1e7ef; background:#fff;
}
.project-rules-tabs button {
  padding:10px 12px 8px; border:0; border-bottom:2px solid transparent;
  background:transparent; color:#5b6777; font:inherit; font-size:14px; font-weight:600; cursor:pointer;
}
.project-rules-tabs button[aria-selected="true"] { border-bottom-color:#0078d4; color:#075eaa; }
.project-rules-tabs button:hover { color:#075eaa; background:#f3f7fc; }
.project-rules-tabs button:focus-visible { outline:2px solid #0078d4; outline-offset:-2px; }
.project-rules-modal > form {
  display:grid; grid-template-rows:minmax(0, 1fr) auto; min-height:0;
  margin:0; padding:0; border:0; border-radius:0; background:#fff; box-shadow:none;
}
.project-rules-modal > form[hidden] { display:none; }
#projectDesignForm { grid-template-rows:auto minmax(0, 1fr) auto; }
.project-design-source {
  display:grid; gap:8px; padding:14px 20px; border-bottom:1px solid #e1e7ef; background:#fff;
}
.project-design-source > div { display:grid; grid-template-columns:minmax(0, 1fr) auto; gap:8px; }
.project-design-source label { font-size:13px; font-weight:600; }
#projectDesignUrl {
  width:100%; min-width:0; min-height:38px; padding:7px 10px;
  border:1px solid #ccd5df; border-radius:6px; background:#fff; color:#233247; font:inherit; font-size:16px;
}
.project-rules-editor {
  display:grid; grid-template-rows:auto minmax(0, 1fr); gap:8px;
  min-height:0; padding:16px 20px; background:#f7f9fc;
}
.project-rules-editor label { font-size:13px; font-weight:600; }
.project-rules-editor textarea {
  width:100%; height:100%; min-height:0; max-height:none; resize:none; padding:12px 14px;
  border:1px solid #ccd5df; border-radius:6px; background:#fff; color:#233247;
  font:inherit; line-height:1.65;
}
#projectDesignResult[hidden] { display:none; }
.project-rules-editor textarea:focus-visible, #projectDesignUrl:focus-visible { outline:2px solid #0078d4; outline-offset:-2px; }
.project-rules-editor textarea::placeholder, #projectDesignUrl::placeholder { color:#64748b; }
.project-design-loading:not([hidden]) {
  display:grid; justify-items:center; align-content:safe center; gap:10px;
  min-height:0; overflow:auto; padding:16px; text-align:center;
  border:1px solid #b6d2ed; border-radius:6px; background:#eef6ff; color:#173a5f;
}
.project-design-loading strong { font-size:18px; }
.project-design-loading p { margin:0; color:#385573; font-size:14px; line-height:1.5; }
.project-design-spinner {
  width:36px; height:36px; border:3px solid #b9d5ef; border-top-color:#0078d4; border-radius:50%;
  animation:project-design-spin .85s linear infinite;
}
@keyframes project-design-spin { to { transform:rotate(360deg); } }
@media(prefers-reduced-motion:reduce) { .project-design-spinner { animation:none; } }
.project-rules-modal footer p { margin:0 auto 0 0; min-width:0; font-size:13px; overflow-wrap:anywhere; }
.project-rules-modal footer p:empty { display:none; }
.project-rules-modal footer {
  display:flex; align-items:center; justify-content:flex-end; gap:12px;
  padding:10px 20px; border-top:1px solid #e1e7ef; background:#fff;
}
.project-rules-modal button[type="submit"], #copyProjectDesign {
  flex:0 0 auto; min-width:80px; min-height:36px; padding:7px 15px; border:1px solid #0078d4; border-radius:5px;
  background:#0078d4; color:#fff; font:inherit; cursor:pointer;
}
#copyProjectDesign { color:#075eaa; border-color:#b6cce1; background:#fff; }
.project-rules-modal button:disabled { opacity:.55; cursor:default; }
@media(max-width:760px){
  .shell>main>header:has(#generalApiConnection:not([hidden])) .header-context { grid-row:4; }
  .project-rules-modal { width:calc(100vw - 24px); height:calc(100dvh - 24px); }
  .project-rules-modal > header, .project-rules-tabs, .project-design-source, .project-rules-editor, .project-rules-modal footer { padding-inline:13px; }
  .project-rules-tabs button { padding-inline:8px; }
}
@media(max-height:620px){
  .project-rules-modal { height:calc(100dvh - 16px); }
  .project-rules-modal > header, .project-design-source, .project-rules-editor, .project-rules-modal footer { padding-block:7px; }
}
